Commit ada48f59 authored by Erik de Castro Lopo's avatar Erik de Castro Lopo
Browse files

share/utf8/charset.c: Cleanup realloc() usage

This version should be logically identical to the previous version
but prevents a false-positive from the cppcheck static analysis
parent 3be45514
......@@ -485,7 +485,7 @@ int charset_convert(const char *fromcode, const char *tocode,
int ret = 0;
struct charset *charset1, *charset2;
char *tobuf, *p, *newbuf;
char *tobuf, *p;
int i, j, wc;
charset1 = charset_find(fromcode);
......@@ -520,8 +520,10 @@ int charset_convert(const char *fromcode, const char *tocode,
*tolen = p - tobuf;
*p++ = '\0';
if (to) {
newbuf = realloc(tobuf, p - tobuf);
*to = newbuf ? newbuf : tobuf;
char *tobuf_saved = tobuf;
*to = realloc(tobuf, p - tobuf);
if (*to == NULL)
*to = tobuf_saved;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment