On Mon, Sep 09, 2013 at 08:41:42PM +0200, Alexandra Khirnova wrote:
> On Mon, Sep 09, 2013 at 11:41:00AM +0200, Alexandra Khirnova wrote:
> >
> > > --- a/libavformat/matroskadec.c
> > > +++ b/libavformat/matroskadec.c
> > > @@ -878,15 +878,16 @@ static int ebml_parse_elem(MatroskaDemuxContext
> > *matroska,
> > > data = (char *)data + syntax->data_offset;
> > > if (syntax->list_elem_size) {
> > > EbmlList *list = data;
> > > - newelem = av_realloc(list->elem,
> > (list->nb_elem+1)*syntax->list_elem_size);
> > > - if (!newelem)
> > > - return AVERROR(ENOMEM);
> > > - list->elem = newelem;
> > > + if ((res = av_reallocp_array(&list->elem,
> > > + list->nb_elem + 1,
> > > + syntax->list_elem_size)) < 0) {
> >
> > I wonder why this does not use plain sizeof.
> >
> looks like list->elem is *void
Yes, this change is correct.
> > > --- a/libavformat/oggdec.c
> > > +++ b/libavformat/oggdec.c
> > > @@ -100,16 +100,13 @@ static int ogg_restore(AVFormatContext *s, int
> > discard)
> > > avio_seek(bc, ost->pos, SEEK_SET);
> > > ogg->curidx = ost->curidx;
> > > ogg->nstreams = ost->nstreams;
> > > - ogg->streams = av_realloc(ogg->streams,
> > > - ogg->nstreams *
> > sizeof(*ogg->streams));
> > > -
> > > - if (ogg->streams) {
> > > + if ((err = av_reallocp_array(&ogg->streams, ogg->nstreams,
> > > + sizeof(*ogg->streams))) < 0) {
> > > + ogg->nstreams = 0;
> > > + return err;
> > > + } else
> > > memcpy(ogg->streams, ost->streams,
> > > ost->nstreams * sizeof(*ogg->streams));
> > > - } else {
> > > - av_free(old_streams);
> > > - ogg->nstreams = 0;
> > > - }
> > > }
> >
> > This changes behavior considerably. The av_free is gone and the memcpy
> > done in a different case.
>
> I think memcpy is done in the same case as before
> Should I free old->streams when ogg->streams are freed by av_reallocp?
I did not look up what old_streams is and missed that it is just a
copy of ogg->streams. The old_streams variable is unused after your
change. You should have seen a (new) warning about that.
Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel