Add safeguard suggested by Alcaro

This commit is contained in:
twinaphex 2017-12-16 00:19:56 +01:00
parent fbdd53b717
commit c63859cca9

View File

@ -391,10 +391,12 @@ int filestream_read_file(const char *path, void **buf, ssize_t *len)
if (content_buf_size < 0)
goto error;
content_buf = malloc((size_t)(content_buf_size + 1));
content_buf = malloc((size_t)(content_buf_size + 1));
if (!content_buf)
goto error;
if ((size_t)(content_buf_size + 1) != (content_buf_size + 1))
goto error;
ret = filestream_read(file, content_buf, (int64_t)content_buf_size);
if (ret < 0)