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

>
> > --- 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?

> _______________________________________________
> libav-devel mailing list
> [email protected]
> https://lists.libav.org/mailman/listinfo/libav-devel
>
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to