diff --git a/libretro-common/formats/xml/rxml.c b/libretro-common/formats/xml/rxml.c index 4b8c26825d..de7a9388c1 100644 --- a/libretro-common/formats/xml/rxml.c +++ b/libretro-common/formats/xml/rxml.c @@ -256,13 +256,18 @@ rxml_document_t *rxml_load_document_string(const char *str) case YXML_ATTRSTART: 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 - 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) - free(attr->attrib); - attr->attrib = strdup(x.attr); + if (attr) + { + if (attr->attrib) + free(attr->attrib); + attr->attrib = strdup(x.attr); + } valptr = buf->val; break; @@ -280,9 +285,12 @@ rxml_document_t *rxml_load_document_string(const char *str) { *valptr = '\0'; - if (attr->value) - free(attr->value); - attr->value = strdup(buf->val); + if (attr) + { + if (attr->value) + free(attr->value); + attr->value = strdup(buf->val); + } valptr = buf->val; } diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index bfecaf0bd9..a851d322a1 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -549,7 +549,8 @@ int64_t filestream_read_file(const char *path, void **buf, int64_t *len) error: if (file) - filestream_close(file); + if (filestream_close(file) != 0) + free(file); if (content_buf) free(content_buf); if (len)