Much better than before, thanks, you're getting close!
On Thu, Dec 19, 2013 at 10:47:46PM -0500, Sean McGovern wrote:
> --- a/libavformat/oggdec.c
> +++ b/libavformat/oggdec.c
> @@ -72,12 +76,25 @@ static int ogg_save(AVFormatContext *s)
> for (i = 0; i < ogg->nstreams; i++) {
> struct ogg_stream *os = ogg->streams + i;
> os->buf = av_mallocz(os->bufsize + FF_INPUT_BUFFER_PADDING_SIZE);
> + if (!os->buf) {
> + int n;
> +
> + for (n = 0; n < i; n++) {
> + struct ogg_stream *os = ogg->streams + n;
> + av_freep(&os->buf);
> + }
> +
> + av_freep(&ost);
> + ret = AVERROR(ENOMEM);
> + goto fail;
> + }
> memcpy(os->buf, ost->streams[i].buf, os->bufpos);
> }
>
> ogg->state = ost;
>
> - return 0;
> +fail:
> + return ret;
> }
Just return directly, you're not doing any work under the fail label.
> @@ -173,10 +190,16 @@ static int ogg_new_stream(AVFormatContext *s, uint32_t
> serial, int new_avstream)
> os->header = -1;
> os->start_granule = OGG_NOGRANULE_VALUE;
>
> + if (!os->buf)
> + return AVERROR(ENOMEM);
> +
> if (new_avstream) {
> st = avformat_new_stream(s, NULL);
> - if (!st)
> + if (!st) {
> + av_freep(&os->buf);
> + av_freep(&os);
> return AVERROR(ENOMEM);
> + }
Don't you have to free os before the first return as well?
Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel