From: Andrey Volk Date: Thu, 22 Apr 2021 22:40:33 +0000 (+0300) Subject: [Core] scan-build: Use of zero allocated in switch_xml_str2utf8() X-Git-Tag: v1.10.7^2~241 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dca7940fb98d6e16ee23491cff3b17b32a6a13e0;p=thirdparty%2Ffreeswitch.git [Core] scan-build: Use of zero allocated in switch_xml_str2utf8() --- diff --git a/src/switch_xml.c b/src/switch_xml.c index a48f9ab96d..cee1a4b833 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -968,6 +968,9 @@ static char *switch_xml_str2utf8(char **s, switch_size_t *len) if (be == -1) return NULL; /* not UTF-16 */ + if (*len <= 3) + return NULL; + u = (char *) switch_must_malloc(max); for (sl = 2; sl < *len - 1; sl += 2) { c = (be) ? (((*s)[sl] & 0xFF) << 8) | ((*s)[sl + 1] & 0xFF) /* UTF-16BE */