summaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorPaweł Hajdan, Jr <phajdan@google.com>2013-01-29 11:41:10 +0000
committerMichael Niedermayer <michaelni@gmx.at>2013-01-29 20:23:02 +0100
commit1d81f7448c8aa7df4aaed612fcd032dbccbd1a96 (patch)
tree33efc243879512b6bfa9a23b33ab7eb29ce687f1 /libavutil
parent0dfc01c2bbf4b71bb56201bc4a393321e15d1b31 (diff)
downloadffmpeg-streaming-1d81f7448c8aa7df4aaed612fcd032dbccbd1a96.zip
ffmpeg-streaming-1d81f7448c8aa7df4aaed612fcd032dbccbd1a96.tar.gz
dict.c: use av_mallocz instead of av_realloc
Memory passed to av_realloc must come from malloc, calloc or realloc, and not e.g. memalign. realloc(3): The realloc() function changes the size of the memory block pointed to by ptr to size bytes. (...) Unless ptr is NULL, it must have been returned by an earlier call to malloc(), calloc() or realloc(). The issue has been found by debugallocation, a part of google-perftools: http://code.google.com/p/gperftools/ . This makes fate pass when using LD_PRELOAD-ed debugallocation. See also earlier discussion http://ffmpeg.org/pipermail/ffmpeg-devel/2013-January/137234.html Signed-off-by: Paweł Hajdan, Jr <phajdan@google.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/dict.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libavutil/dict.c b/libavutil/dict.c
index 06f963c..23816e8 100644
--- a/libavutil/dict.c
+++ b/libavutil/dict.c
@@ -94,10 +94,12 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags
m->elems[m->count].value = (char*)(intptr_t)value;
} else if (oldval && flags & AV_DICT_APPEND) {
int len = strlen(oldval) + strlen(value) + 1;
- if (!(oldval = av_realloc(oldval, len)))
+ char *newval = av_mallocz(len);
+ if (!newval)
return AVERROR(ENOMEM);
- av_strlcat(oldval, value, len);
- m->elems[m->count].value = oldval;
+ av_strlcat(newval, oldval, len);
+ av_strlcat(newval, value, len);
+ m->elems[m->count].value = newval;
} else
m->elems[m->count].value = av_strdup(value);
m->count++;
OpenPOWER on IntegriCloud