mirror of https://git.ffmpeg.org/ffmpeg.git
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>
This commit is contained in:
parent
0dfc01c2bb
commit
1d81f7448c
|
@ -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++;
|
||||
|
|
Loading…
Reference in New Issue