Fix error from cppcheck:
[src/rgw/rgw_xml.cc:212]: (error) Common realloc mistake: 'buf'
nulled but not freed upon failure
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
(cherry picked from commit
d48cc789ea075ba2745754035640ada4131b2119)
bool RGWXMLParser::parse(const char *_buf, int len, int done)
{
int pos = buf_len;
- buf = (char *)realloc(buf, buf_len + len);
- if (!buf)
+ char *tmp_buf;
+ tmp_buf = (char *)realloc(buf, buf_len + len);
+ if (tmp_buf == NULL){
+ free(buf);
+ buf = NULL;
return false;
+ } else {
+ buf = tmp_buf;
+ }
+
memcpy(&buf[buf_len], _buf, len);
buf_len += len;