overflow errors
This commit is contained in:
+6
-3
@@ -158,10 +158,13 @@ char *editorPrompt(char *prompt, char *placeHolder, char bPathMode) {
|
||||
} else if (!iscntrl(c) && c < 256) {
|
||||
if (buf_len == buf_size - 1) {
|
||||
buf_size *= 2;
|
||||
buf = realloc(buf, buf_size);
|
||||
char *new_buf = realloc(buf, buf_size);
|
||||
if (!new_buf) {
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
buf = new_buf;
|
||||
}
|
||||
buf[buf_len++] = (char)c;
|
||||
buf[buf_len] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user