aboutsummaryrefslogtreecommitdiff
path: root/src/any_ini.h
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2024-07-10 23:49:13 +0200
committerFederico Angelilli <code@fedang.net>2024-07-10 23:49:13 +0200
commit26aaffc0e7293e4d4e48362159572e205c082068 (patch)
treecbc55034ab2c6756ee633da1c171209c0535ea81 /src/any_ini.h
parent6f7c05c10766be1e331a5668ef534f5e85cecace (diff)
Finish config reader
Diffstat (limited to 'src/any_ini.h')
-rw-r--r--src/any_ini.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/any_ini.h b/src/any_ini.h
index f05b579..9d9afe6 100644
--- a/src/any_ini.h
+++ b/src/any_ini.h
@@ -424,7 +424,10 @@ static char *any_ini_stream_until(any_ini_stream_t *ini, size_t start, char c)
// Copy current buffer and refill
case '\0':
tmp = ANY_INI_REALLOC(value, size + ini->cursor - start);
- if (!tmp) return value;
+ if (!tmp) {
+ value[size - 1] = 0;
+ return value;
+ }
size += any_ini_copy(tmp + size, ini->buffer + start, ini->cursor - start);
value = tmp;
@@ -469,8 +472,11 @@ static char *any_ini_stream_until(any_ini_stream_t *ini, size_t start, char c)
}
}
- tmp = ANY_INI_REALLOC(value, size + ini->cursor - start);
- if (!tmp) return value;
+ tmp = ANY_INI_REALLOC(value, size + ini->cursor - start + 1);
+ if (!tmp) {
+ value[size - 1] = 0;
+ return value;
+ }
size += any_ini_copy(tmp + size, ini->buffer + start, ini->cursor - start);
size = any_ini_trim(tmp, 0, size);