filestream_getline - be safer
This commit is contained in:
parent
e8ff299fd4
commit
6208981ad3
|
@ -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')
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue