(libretro-common) Prevent more static code analysis warnings

This commit is contained in:
twinaphex 2020-06-29 20:31:14 +02:00
parent f83f0b2d44
commit 5cfc4defc6
2 changed files with 18 additions and 9 deletions

View File

@ -256,13 +256,18 @@ rxml_document_t *rxml_load_document_string(const char *str)
case YXML_ATTRSTART: case YXML_ATTRSTART:
if (attr) if (attr)
attr = attr->next = (struct rxml_attrib_node*)calloc(1, sizeof(*attr)); attr = attr->next = (struct rxml_attrib_node*)
calloc(1, sizeof(*attr));
else else
attr = node->attrib = (struct rxml_attrib_node*)calloc(1, sizeof(*attr)); attr = node->attrib = (struct rxml_attrib_node*)
calloc(1, sizeof(*attr));
if (attr->attrib) if (attr)
free(attr->attrib); {
attr->attrib = strdup(x.attr); if (attr->attrib)
free(attr->attrib);
attr->attrib = strdup(x.attr);
}
valptr = buf->val; valptr = buf->val;
break; break;
@ -280,9 +285,12 @@ rxml_document_t *rxml_load_document_string(const char *str)
{ {
*valptr = '\0'; *valptr = '\0';
if (attr->value) if (attr)
free(attr->value); {
attr->value = strdup(buf->val); if (attr->value)
free(attr->value);
attr->value = strdup(buf->val);
}
valptr = buf->val; valptr = buf->val;
} }

View File

@ -549,7 +549,8 @@ int64_t filestream_read_file(const char *path, void **buf, int64_t *len)
error: error:
if (file) if (file)
filestream_close(file); if (filestream_close(file) != 0)
free(file);
if (content_buf) if (content_buf)
free(content_buf); free(content_buf);
if (len) if (len)