mirror of
https://github.com/libretro/RetroArch
synced 2025-02-11 15:40:28 +00:00
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 *filestream_getline(RFILE *stream)
|
||||||
{
|
{
|
||||||
char* newline = (char*)malloc(9);
|
|
||||||
char* newline_tmp = NULL;
|
char* newline_tmp = NULL;
|
||||||
size_t cur_size = 8;
|
size_t cur_size = 8;
|
||||||
size_t idx = 0;
|
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;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
in = filestream_getc(stream);
|
||||||
|
|
||||||
while (in != EOF && in != '\n')
|
while (in != EOF && in != '\n')
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user