1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-12-19 13:53:21 +01:00

Fix a few issues

- realloc needs to be error checked
- use correct format specifiers
- make sure optarg and DATA_FILE aren't null before using them
This commit is contained in:
jfreegman
2020-11-02 18:08:54 -05:00
parent e7a0c32a68
commit 1bbd50aac7
8 changed files with 29 additions and 11 deletions

View File

@@ -100,9 +100,19 @@ static char *read_into_dyn_buffer(FILE *stream)
int length = dyn_buffer_size + strlen(input_ptr);
if (dyn_buffer) {
dyn_buffer = (char *) realloc(dyn_buffer, length);
char *tmp = realloc(dyn_buffer, length);
if (tmp == NULL) {
return NULL;
}
dyn_buffer = tmp;
} else {
dyn_buffer = (char *) malloc(length);
dyn_buffer = malloc(length);
if (dyn_buffer == NULL) {
return NULL;
}
}
strcpy(dyn_buffer + dyn_buffer_size - 1, input_ptr);