summaryrefslogtreecommitdiff
path: root/src/plugin_common/tags.c
diff options
context:
space:
mode:
authorMartijn van Beurden <mvanb1@gmail.com>2022-08-03 13:52:19 +0200
committerMartijn van Beurden <mvanb1@gmail.com>2022-08-20 16:03:53 +0200
commit21fe95ee828b0b9b944f6aa0bb02d24fbb981815 (patch)
tree781a94a1982b0f5e69f163658781b0d686792a8c /src/plugin_common/tags.c
parentb715d7b9fe90f5b411ae1c159553c7c287f0789a (diff)
downloadflac-21fe95ee828b0b9b944f6aa0bb02d24fbb981815.tar.gz
Add and use _nofree variants of safe_realloc functions
Parts of the code use realloc like x = safe_realloc(x, somesize); when this is the case, the safe_realloc variant used must free the old memory block in case it fails, otherwise it will leak. However, there are also instances in the code where handling is different: if (0 == (x = safe_realloc(y, somesize))) return false in this case, y should not be freed, as y is not set to NULL we could encounter double frees. Here the safe_realloc_nofree functions are used.
Diffstat (limited to 'src/plugin_common/tags.c')
-rw-r--r--src/plugin_common/tags.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/plugin_common/tags.c b/src/plugin_common/tags.c
index e9227444..ffd846b6 100644
--- a/src/plugin_common/tags.c
+++ b/src/plugin_common/tags.c
@@ -317,7 +317,7 @@ FLAC__bool FLAC_plugin__tags_add_tag_utf8(FLAC__StreamMetadata *tags, const char
const size_t value_len = strlen(value);
const size_t separator_len = strlen(separator);
FLAC__byte *new_entry;
- if(0 == (new_entry = safe_realloc_add_4op_(entry->entry, entry->length, /*+*/value_len, /*+*/separator_len, /*+*/1)))
+ if(0 == (new_entry = safe_realloc_nofree_add_4op_(entry->entry, entry->length, /*+*/value_len, /*+*/separator_len, /*+*/1)))
return false;
memcpy(new_entry+entry->length, separator, separator_len);
entry->length += separator_len;