From: Andrey Volk Date: Sun, 25 Apr 2021 01:12:50 +0000 (+0300) Subject: [Core] scan-build: fix false-positive use-after-free in switch_xml_internal_dtd() X-Git-Tag: v1.10.7^2~266 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b59c28bdbd33f2a119c0f353d6d4376736bd6602;p=thirdparty%2Ffreeswitch.git [Core] scan-build: fix false-positive use-after-free in switch_xml_internal_dtd() --- diff --git a/src/switch_xml.c b/src/switch_xml.c index b05358741c..94268da358 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -839,6 +839,8 @@ static short switch_xml_internal_dtd(switch_xml_root_t root, char *s, switch_siz if (!*s) break; else if (!strncmp(s, "ent; ent[i]; i++); + use_pe = (*c == '%'); + for (i = 0, ent = (use_pe) ? pe : root->ent; ent[i]; i++); sstmp = (char **) switch_must_realloc(ent, (i + 3) * sizeof(char *)); /* space for next ent */ ent = sstmp; - if (*c == '%') + if (use_pe) pe = ent; else root->ent = ent;