[FFmpeg-devel] [PATCH 06/10] segment.c: Add allocation failure checks.
Michael Niedermayer
michael at niedermayer.cc
Tue May 29 00:45:23 EEST 2018
On Mon, May 28, 2018 at 08:27:07PM +0200, Stephan Holljes wrote:
> Signed-off-by: Stephan Holljes <klaxa1337 at googlemail.com>
> ---
> segment.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/segment.c b/segment.c
> index c40d1ad..986aeb5 100644
> --- a/segment.c
> +++ b/segment.c
> @@ -82,6 +82,10 @@ int segment_write(void *opaque, unsigned char *buf, int buf_size)
> struct Segment *seg = (struct Segment*) opaque;
> seg->size += buf_size;
> seg->buf = (unsigned char*) av_realloc(seg->buf, seg->size);
> + if (!seg->buf) {
> + av_log(NULL, AV_LOG_ERROR, "Could not grow segment.\n");
> + return AVERROR(ENOMEM);
> + }
> memcpy(seg->buf + seg->size - buf_size, buf, buf_size);
> return buf_size;
> }
> @@ -110,6 +114,10 @@ void segment_init(struct Segment **seg_p, AVFormatContext *fmt)
> int i;
> AVStream *in_stream, *out_stream;
> struct Segment *seg = (struct Segment*) av_malloc(sizeof(struct Segment));
> + if (!seg) {
> + av_log(fmt, AV_LOG_ERROR, "Could not allocate segment.\n");
> + return;
> + }
i didnt look at the surrounding code but just from the patch
segment_init fails and its void, not returning an error, that seems odd
does this work ?
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180528/673798aa/attachment.sig>
More information about the ffmpeg-devel
mailing list