aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2022-07-18 13:55:06 +0200
committerJan200101 <sentrycraft123@gmail.com>2022-07-18 13:55:06 +0200
commit027cfbd2cd212760424b2fa96bd6aeb755c53155 (patch)
tree8828221d1e75e9e39f47cb05239b651d13b995eb
parent0690e13a39ccfc6e37f1ed6eb5e82032c76d3a34 (diff)
downloadcgci-027cfbd2cd212760424b2fa96bd6aeb755c53155.tar.gz
cgci-027cfbd2cd212760424b2fa96bd6aeb755c53155.zip
correctly deal with multiple comments in a row, only allocate config values if possible, and free duplicates
-rw-r--r--src/parser.c19
-rw-r--r--src/ui.c2
2 files changed, 17 insertions, 4 deletions
diff --git a/src/parser.c b/src/parser.c
index 052acb4..d8ad576 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -73,7 +73,8 @@ void parse_config()
assert((size_t)(tail - buf) <= file_size);
++tail;
}
- head = tail+1;;
+
+ head = tail++;
continue;
}
else if (*tail == '=')
@@ -119,11 +120,23 @@ void parse_config()
}
else if (!strcmp(key, "project.script"))
{
- config.projects[config.project_count-1].script_path = strdup(value);
+ if (config.project_count > 0)
+ {
+ if (config.projects[config.project_count-1].script_path)
+ free(config.projects[config.project_count-1].script_path);
+
+ config.projects[config.project_count-1].script_path = strdup(value);
+ }
}
else if (!strcmp(key, "project.description"))
{
- config.projects[config.project_count-1].description = strdup(value);
+ if (config.project_count > 0)
+ {
+ if (config.projects[config.project_count-1].description)
+ free(config.projects[config.project_count-1].description);
+
+ config.projects[config.project_count-1].description = strdup(value);
+ }
}
key = NULL;
diff --git a/src/ui.c b/src/ui.c
index 25c810e..2740ef7 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -329,7 +329,7 @@ void print_project_list()
"<td class=\"%s\">%s</td>"
"</tr>",
project->name, project->name,
- project->description,
+ project->description ? project->description : "",
time, buildtime,
class, status
);