diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 0e1046d20f..0d3d8142fb 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -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)