diff options
author | Martijn van Beurden <mvanb1@gmail.com> | 2022-08-03 13:52:19 +0200 |
---|---|---|
committer | Martijn van Beurden <mvanb1@gmail.com> | 2022-08-20 16:03:53 +0200 |
commit | 21fe95ee828b0b9b944f6aa0bb02d24fbb981815 (patch) | |
tree | 781a94a1982b0f5e69f163658781b0d686792a8c /src/share/utf8/iconvert.c | |
parent | b715d7b9fe90f5b411ae1c159553c7c287f0789a (diff) | |
download | flac-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/share/utf8/iconvert.c')
-rw-r--r-- | src/share/utf8/iconvert.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/share/utf8/iconvert.c b/src/share/utf8/iconvert.c index 8ab53c10..876c06e8 100644 --- a/src/share/utf8/iconvert.c +++ b/src/share/utf8/iconvert.c @@ -149,7 +149,7 @@ int iconvert(const char *fromcode, const char *tocode, iconv_close(cd1); return ret; } - newbuf = safe_realloc_add_2op_(utfbuf, (ob - utfbuf), /*+*/1); + newbuf = safe_realloc_nofree_add_2op_(utfbuf, (ob - utfbuf), /*+*/1); if (!newbuf) goto fail; ob = (ob - utfbuf) + newbuf; |