Note to self: use strncpy always.
parent
0a9f987d22
commit
1aae27409b
|
|
@ -570,7 +570,7 @@ char* get_line(int fd) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
buffer[i] = '\0';
|
buffer[i] = '\0';
|
||||||
output = strcpy(ecalloc(i, sizeof(*output)), buffer);
|
output = strncpy(ecalloc(i, sizeof(char)), buffer, i*sizeof(char));
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
@ -579,6 +579,7 @@ void on_stdin(void) {
|
||||||
while (1) {
|
while (1) {
|
||||||
char *buffer = get_line(STDIN_FILENO);
|
char *buffer = get_line(STDIN_FILENO);
|
||||||
if (!buffer || !strlen(buffer)) {
|
if (!buffer || !strlen(buffer)) {
|
||||||
|
if (buffer)
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue