diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 9975342ddd..a9de8db794 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -1028,11 +1028,11 @@ static int cheevos_parse_expression(cheevos_expr_t *expr, const char* mem) cheevos_term_t *terms = NULL; char *end = NULL; - if (expr) - { - expr->count = 1; - expr->compare_count = 1; - } + if (!expr) + return -1; + + expr->count = 1; + expr->compare_count = 1; for (aux = mem;; aux++) { diff --git a/libretro-common/formats/png/rpng_encode.c b/libretro-common/formats/png/rpng_encode.c index cd483e39dd..92e25e16f4 100644 --- a/libretro-common/formats/png/rpng_encode.c +++ b/libretro-common/formats/png/rpng_encode.c @@ -354,7 +354,8 @@ static bool rpng_save_image(const char *path, GOTO_END_ERROR(); end: - filestream_close(file); + if (file) + filestream_close(file); free(encode_buf); free(deflate_buf); free(rgba_line); diff --git a/libretro-common/vfs/vfs_implementation.c b/libretro-common/vfs/vfs_implementation.c index ba962840ed..14eb11afd0 100644 --- a/libretro-common/vfs/vfs_implementation.c +++ b/libretro-common/vfs/vfs_implementation.c @@ -251,12 +251,9 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(const char *path, uns if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) { - if (!mode_str) - goto error; + FILE *fp = fopen_utf8(path, mode_str); - stream->fp = fopen_utf8(path, mode_str); - - if (!stream->fp) + if (!fp) goto error; /* Regarding setvbuf: @@ -269,6 +266,7 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(const char *path, uns * Since C89 does not support specifying a null buffer with a non-zero size, we create and track our own buffer for it. */ /* TODO: this is only useful for a few platforms, find which and add ifdef */ + stream->fp = fp; stream->buf = (char*)calloc(1, 0x4000); setvbuf(stream->fp, stream->buf, _IOFBF, 0x4000); } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index b3b2154028..7cb6b230a7 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1065,7 +1065,7 @@ static void xmb_update_thumbnail_path(void *data, unsigned i) sizeof(new_path)); end: - if (!string_is_empty(new_path)) + if (xmb && !string_is_empty(new_path)) xmb->thumbnail_file_path = strdup(new_path); menu_entry_free(&entry); }