filestream_getline - be safer

This commit is contained in:
twinaphex 2018-01-22 21:32:36 +01:00
parent e8ff299fd4
commit 6208981ad3

View File

@ -460,14 +460,20 @@ bool filestream_write_file(const char *path, const void *data, ssize_t size)
char *filestream_getline(RFILE *stream)
{
char* newline = (char*)malloc(9);
char* newline_tmp = NULL;
size_t cur_size = 8;
size_t idx = 0;
int in = filestream_getc(stream);
int in = 0;
char* newline = (char*)malloc(9);
if (!newline)
if (!stream || !newline)
{
if (newline)
free(newline);
return NULL;
}
in = filestream_getc(stream);
while (in != EOF && in != '\n')
{