Solving a bug with empty files

This commit is contained in:
AnonymusRaccoon
2020-02-18 14:54:54 +01:00
parent e060848bef
commit f923c6d56c
2 changed files with 4 additions and 1 deletions
+2
View File
@@ -15,6 +15,8 @@ int xml_getstringdata(node *n, char **nodestr)
{
dictionary *prop = malloc(sizeof(dictionary));
if (!prop)
return (-1);
prop->key = my_strdup("data");
prop->value = my_strdup(*nodestr);
prop->next = NULL;
+2 -1
View File
@@ -80,7 +80,8 @@ node *xml_parse(const char *path)
if (fd < 0)
return (NULL);
fstat(fd, &stats);
if (fstat(fd, &stats) < 0 || stats.st_size <= 0)
return (NULL);
nodestr = malloc(stats.st_size + 1);
if (nodestr) {
count = read(fd, nodestr, stats.st_size);