(movie.c) Be more careful with allocations

This commit is contained in:
twinaphex 2016-12-25 01:57:15 +01:00
parent bb4888ae22
commit 4ddbde8a09

View File

@ -208,6 +208,7 @@ static void bsv_movie_free(bsv_movie_t *handle)
static bsv_movie_t *bsv_movie_init(const char *path,
enum rarch_movie_type type)
{
size_t *frame_pos = NULL;
bsv_movie_t *handle = (bsv_movie_t*)calloc(1, sizeof(*handle));
if (!handle)
return NULL;
@ -222,9 +223,11 @@ static bsv_movie_t *bsv_movie_init(const char *path,
/* Just pick something really large
* ~1 million frames rewind should do the trick. */
if (!(handle->frame_pos = (size_t*)calloc((1 << 20), sizeof(size_t))))
if (!(frame_pos = (size_t*)calloc((1 << 20), sizeof(size_t))))
goto error;
handle->frame_pos = frame_pos;
handle->frame_pos[0] = handle->min_file_pos;
handle->frame_mask = (1 << 20) - 1;