summaryrefslogtreecommitdiff
path: root/plugins/yaml/reader.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/yaml/reader.c')
-rw-r--r--plugins/yaml/reader.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/plugins/yaml/reader.c b/plugins/yaml/reader.c
index c8852bb..54273c1 100644
--- a/plugins/yaml/reader.c
+++ b/plugins/yaml/reader.c
@@ -197,20 +197,25 @@ GYamlReader *g_yaml_reader_new_from_content(const char *content, size_t length)
*iter != '\0';
iter = ++saved, saved = strchr(iter, '\n'), number++)
{
- *saved = '\0';
+ if (saved != NULL)
+ *saved = '\0';
- if (*iter == '\0')
- continue;
+ if (*iter != '\0')
+ {
+ line = g_yaml_line_new(iter, number);
- line = g_yaml_line_new(iter, number);
+ if (line == NULL)
+ goto format_error;
- if (line == NULL)
- goto format_error;
+ result->lines = realloc(result->lines, ++result->count * sizeof(GYamlLine *));
- result->lines = realloc(result->lines, ++result->count * sizeof(GYamlLine *));
+ g_object_ref_sink(G_OBJECT(line));
+ result->lines[result->count - 1] = line;
- g_object_ref_sink(G_OBJECT(line));
- result->lines[result->count - 1] = line;
+ }
+
+ if (saved == NULL)
+ break;
}