From f770ea856018422241190cb245e46c0e19554e95 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 22 Jan 2017 18:22:45 +0100 Subject: [PATCH] (movie.c) Try to be more safe in init_playback --- movie.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/movie.c b/movie.c index cda896b2f0..dc87fa4d38 100644 --- a/movie.c +++ b/movie.c @@ -110,14 +110,16 @@ static bool init_playback(bsv_movie_t *handle, const char *path) if (state_size) { - retro_ctx_serialize_info_t serial_info; retro_ctx_size_info_t info; + retro_ctx_serialize_info_t serial_info; + uint8_t *buf = (uint8_t*)malloc(state_size); - handle->state = (uint8_t*)malloc(state_size); - handle->state_size = state_size; - if (!handle->state) + if (!buf) return false; + handle->state = buf; + handle->state_size = state_size; + if (fread(handle->state, 1, state_size, handle->file) != state_size) { RARCH_ERR("%s\n", msg_hash_to_str(MSG_COULD_NOT_READ_STATE_FROM_MOVIE));