LIB: Prevent the possible issue of dereferencing a NULL pointer.

This commit is contained in:
Rom Walton 2017-07-16 14:22:20 -07:00
parent daee3b66fc
commit a91f4c6408
1 changed files with 7 additions and 4 deletions

View File

@ -623,17 +623,20 @@ bool XML_PARSER::parse_str(const char* start_tag, char* buf, int len) {
// same, for std::string
//
bool XML_PARSER::parse_string(const char* start_tag, string& str) {
bool flag = false;
if (is_empty_string(parsed_tag, start_tag)) {
str = "";
return true;
}
if (strcmp(parsed_tag, start_tag)) return false;
char *buf=(char *)malloc(MAX_XML_STRING);
bool flag = parse_str_aux(start_tag, buf, MAX_XML_STRING);
if (flag) {
str = buf;
if (buf) {
flag = parse_str_aux(start_tag, buf, MAX_XML_STRING);
if (flag) {
str = buf;
}
free(buf);
}
free(buf);
return flag;
}