Browse code

Merge commit 'c3bd1d60af97e8d2568dac9fcce7bdabb4ff93c8'

* commit 'c3bd1d60af97e8d2568dac9fcce7bdabb4ff93c8':
formats: Check memory allocations

Conflicts:
libavfilter/formats.c

See: 527ca3985c736ffe077a82fdf3616f0fd571b923
Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2015/03/13 06:39:27
Showing 1 changed files
... ...
@@ -281,12 +281,13 @@ int ff_fmt_is_in(int fmt, const int *fmts)
281 281
         for (count = 0; fmts[count] != -1; count++)                     \
282 282
             ;                                                           \
283 283
     formats = av_mallocz(sizeof(*formats));                             \
284
-    if (!formats) return NULL;                                          \
284
+    if (!formats)                                                       \
285
+        return NULL;                                                    \
285 286
     formats->count_field = count;                                       \
286 287
     if (count) {                                                        \
287 288
         formats->field = av_malloc_array(count, sizeof(*formats->field));      \
288 289
         if (!formats->field) {                                          \
289
-            av_free(formats);                                           \
290
+            av_freep(&formats);                                         \
290 291
             return NULL;                                                \
291 292
         }                                                               \
292 293
     }
... ...
@@ -415,6 +416,8 @@ AVFilterChannelLayouts *ff_all_channel_counts(void)
415 415
 do {                                                                 \
416 416
     *ref = f;                                                        \
417 417
     f->refs = av_realloc(f->refs, sizeof(*f->refs) * ++f->refcount); \
418
+    if (!f->refs)                                                    \
419
+        return;                                                      \
418 420
     f->refs[f->refcount-1] = ref;                                    \
419 421
 } while (0)
420 422