On Tue, Feb 17, 2015 at 4:55 PM, Vittorio Giovara < [email protected]> wrote:
> On Tue, Feb 17, 2015 at 10:12 AM, <[email protected]> wrote: > > From: Federico Tomassetti <[email protected]> > > > > Bug-Id: CID 1257798 > > Bug-Id: CID 1257805 > > --- > > libavformat/oggdec.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c > > index 760cc25..1dc3145 100644 > > --- a/libavformat/oggdec.c > > +++ b/libavformat/oggdec.c > > @@ -63,6 +63,8 @@ static int ogg_save(AVFormatContext *s) > > struct ogg *ogg = s->priv_data; > > struct ogg_state *ost = > > av_malloc(sizeof(*ost) + (ogg->nstreams - 1) * > sizeof(*ogg->streams)); > > + if (!ost) > > + return AVERROR(ENOMEM); > > int i; > > ost->pos = avio_tell(s->pb); > > ost->curidx = ogg->curidx; > > @@ -190,6 +192,8 @@ static int ogg_new_buf(struct ogg *ogg, int idx) > > { > > struct ogg_stream *os = ogg->streams + idx; > > uint8_t *nb = av_malloc(os->bufsize + FF_INPUT_BUFFER_PADDING_SIZE); > > + if (!nb) > > + return AVERROR(ENOMEM); > > int size = os->bufpos - os->pstart; > > > > if (os->buf) { > > This won't do, you can't mix if checks and variable declarations. > It should actually fail to build, I assume you ran make before sending > the patch right? > Finally there is at least one more allocation that should be checked, > always double check searching for 'alloc' when writing this kind of > patches. > ok, I ran make fate and it passed. I know it sounds strange but my compiler seems happy with it... however I fixed it by moving the checks below the declarations (sorry for the mistake). About the other check, I guess you refer to the av_mallocz in the for loop: I saw it but it was not super-super-super trivial, because if a malloc fails we want probably to rerun the loop up to the current point freeing the previously allocated space. Given the errors I am already doing with extra-trivial tasks I planned to do that later :) I will send the updated patch (thank you again for the patience) Federico > -- > Vittorio > _______________________________________________ > libav-devel mailing list > [email protected] > https://lists.libav.org/mailman/listinfo/libav-devel > -- Website at http://www.federico-tomassetti.it _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
