mirror of
https://github.com/zoriya/xmlParser.git
synced 2026-06-11 21:36:16 +00:00
Solving a bug with empty files
This commit is contained in:
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user