History

dict.c: Free non-strduped av_dict_set arguments on error.

Unfortunately this was not explicitly documented and thus might be risky. But all uses I could find in FFmpeg and one in VLC had a memleak in these cases, and I could not find any that relied on the previous behaviour.

Reimar Döffinger committed 12 years ago

Commit 8fc9bd01 parent 45c7f394 files · +13 −1Browse files

Unified · Split

4 files
  1. doc/APIchanges +5 −0
  2. libavutil/dict.c +2 −0
  3. libavutil/dict.h +5 −0
  4. libavutil/version.h +1 −1
doc/APIchanges+5−0
@@ -15,6 +15,11 @@ libavutil: 2014-08-09 · 14 unmodified lines
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182014-08-23 - xxxxxxx - lavu 54.7.100 - dict.h
19 AV_DICT_DONT_STRDUP_KEY and AV_DICT_DONT_STRDUP_VAL arguments are now
20 freed even on error. This is consistent with the behaviour all users
21 of it we could find expect.
22
182014-08-21 - 980a5b0 - lavu 54.6.100 - frame.h motion_vector.h232014-08-21 - 980a5b0 - lavu 54.6.100 - frame.h motion_vector.h
19 Add AV_FRAME_DATA_MOTION_VECTORS side data and AVMotionVector structure24 Add AV_FRAME_DATA_MOTION_VECTORS side data and AVMotionVector structure
20 25
libavutil/dict.c+2−0
@@ -126,6 +126,8 @@ err_out: · 125 unmodified lines
126 av_free(m->elems);126 av_free(m->elems);
127 av_freep(pm);127 av_freep(pm);
128 }128 }
129 if (flags & AV_DICT_DONT_STRDUP_KEY) av_free(key);
130 if (flags & AV_DICT_DONT_STRDUP_VAL) av_free(value);
129 return AVERROR(ENOMEM);131 return AVERROR(ENOMEM);
130}132}
131 133
libavutil/dict.h+5−0
@@ -115,6 +115,9 @@ int av_dict_count(const AVDictionary *m); · 114 unmodified lines
115/**115/**
116 * Set the given entry in *pm, overwriting an existing entry.116 * Set the given entry in *pm, overwriting an existing entry.
117 *117 *
118 * Note: If AV_DICT_DONT_STRDUP_KEY or AV_DICT_DONT_STRDUP_VAL is set,
119 * these arguments will be freed on error.
120 *
118 * @param pm pointer to a pointer to a dictionary struct. If *pm is NULL121 * @param pm pointer to a pointer to a dictionary struct. If *pm is NULL
119 * a dictionary struct is allocated and put in *pm.122 * a dictionary struct is allocated and put in *pm.
120 * @param key entry key to add to *pm (will be av_strduped depending on flags)123 * @param key entry key to add to *pm (will be av_strduped depending on flags)
@@ -127,6 +130,8 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags · 6 unmodified lines
127/**130/**
128 * Convenience wrapper for av_dict_set that converts the value to a string131 * Convenience wrapper for av_dict_set that converts the value to a string
129 * and stores it.132 * and stores it.
133 *
134 * Note: If AV_DICT_DONT_STRDUP_KEY is set, key will be freed on error.
130 */135 */
131int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags);136int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags);
132 137
libavutil/version.h+1−1
@@ -56,7 +56,7 @@ · 55 unmodified lines
56 */56 */
57 57
58#define LIBAVUTIL_VERSION_MAJOR 5458#define LIBAVUTIL_VERSION_MAJOR 54
59#define LIBAVUTIL_VERSION_MINOR 659#define LIBAVUTIL_VERSION_MINOR 7
60#define LIBAVUTIL_VERSION_MICRO 10060#define LIBAVUTIL_VERSION_MICRO 100
61 61
62#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \62#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t