From 64da817eec7670063760067eb17e7245070966a7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 13 Oct 2013 23:12:12 -0400 Subject: [PATCH 1/7] Fix a memory leak in function gl_init_font in ps_libdbgfont.c --- gfx/fonts/ps_libdbgfont.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gfx/fonts/ps_libdbgfont.c b/gfx/fonts/ps_libdbgfont.c index be5d18bec9..ade23ba409 100644 --- a/gfx/fonts/ps_libdbgfont.c +++ b/gfx/fonts/ps_libdbgfont.c @@ -54,6 +54,7 @@ static bool gl_init_font(void *data, const char *font_path, float font_size) #endif DbgFontInit(&cfg); + free(handle); return true; } From b4e5b6bb71e744afb8ec9dc15ed2ae3b980d004d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 13 Oct 2013 23:13:38 -0400 Subject: [PATCH 2/7] Fix two memory leaks in function align_program in py_state.c --- gfx/py_state/py_state.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gfx/py_state/py_state.c b/gfx/py_state/py_state.c index 3a86453b97..461138d07a 100644 --- a/gfx/py_state/py_state.c +++ b/gfx/py_state/py_state.c @@ -210,13 +210,17 @@ static char *align_program(const char *program) size_t prog_size = strlen(program) + 1; char *new_prog = (char*)calloc(1, prog_size); if (!new_prog) + { + free(prog); return NULL; + } char *save; char *line = dupe_newline(strtok_r(prog, "\n", &save)); if (!line) { free(prog); + free(new_prog); return NULL; } From 080436fd23c076ef773cc803c65378d4242e05e5 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 13 Oct 2013 23:16:12 -0400 Subject: [PATCH 3/7] Remove a redundant if statement in function set_direct_pix_conv in scaler.c. This branch already exists in this if statement chain, see the third else-if statement. --- gfx/scaler/scaler.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/gfx/scaler/scaler.c b/gfx/scaler/scaler.c index 3fa9cb3b77..a015ea63d3 100644 --- a/gfx/scaler/scaler.c +++ b/gfx/scaler/scaler.c @@ -84,8 +84,6 @@ static bool set_direct_pix_conv(struct scaler_ctx *ctx) ctx->direct_pixconv = conv_argb8888_bgr24; else if (ctx->in_fmt == SCALER_FMT_0RGB1555 && ctx->out_fmt == SCALER_FMT_BGR24) ctx->direct_pixconv = conv_0rgb1555_bgr24; - else if (ctx->in_fmt == SCALER_FMT_RGB565 && ctx->out_fmt == SCALER_FMT_BGR24) - ctx->direct_pixconv = conv_rgb565_bgr24; else if (ctx->in_fmt == SCALER_FMT_ARGB8888 && ctx->out_fmt == SCALER_FMT_ABGR8888) ctx->direct_pixconv = conv_argb8888_abgr8888; else From 83da083a2469919b0e4a4b5a1478169df62b8bad Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 13 Oct 2013 23:19:50 -0400 Subject: [PATCH 4/7] Fix a memory leak in function rglCgCreateProgramGroupFromFile in rgl_ps3_cg.cpp. --- ps3/rgl/src/ps3/rgl_ps3_cg.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ps3/rgl/src/ps3/rgl_ps3_cg.cpp b/ps3/rgl/src/ps3/rgl_ps3_cg.cpp index 75e447a7e1..7b76b62759 100644 --- a/ps3/rgl/src/ps3/rgl_ps3_cg.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3_cg.cpp @@ -266,6 +266,7 @@ static CGprogramGroup rglCgCreateProgramGroupFromFile( CGcontext ctx, const char if ( NULL == ptr ) { rglCgRaiseError( CG_MEMORY_ALLOC_ERROR ); + fclose(fp); return ( CGprogramGroup )NULL; } From 51d7ec925e23e5cae78d81de4079fd6c0956dd5e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 13 Oct 2013 23:22:41 -0400 Subject: [PATCH 5/7] Fix a memory leak in function get_sha1 in retrolaunch/main.c. --- tools/retrolaunch/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/retrolaunch/main.c b/tools/retrolaunch/main.c index 19e9aff19c..105d28a1af 100644 --- a/tools/retrolaunch/main.c +++ b/tools/retrolaunch/main.c @@ -134,6 +134,7 @@ static int get_sha1(const char *path, char *result) sha.Message_Digest[1], sha.Message_Digest[2], sha.Message_Digest[3], sha.Message_Digest[4]); + close(fd); return 0; } From 98bdd6896e893a5d967682e15306e69b13812d4b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 13 Oct 2013 23:24:49 -0400 Subject: [PATCH 6/7] Fix a memory leak in function find_first_cue in retrolaunch/cd_detect.c. --- tools/retrolaunch/cd_detect.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/retrolaunch/cd_detect.c b/tools/retrolaunch/cd_detect.c index 102d1512d4..f6c407a66d 100644 --- a/tools/retrolaunch/cd_detect.c +++ b/tools/retrolaunch/cd_detect.c @@ -254,6 +254,7 @@ int find_first_cue(const char* m3u_path, char* cue_path, size_t max_len) { skip = 0; } else if(midstream) { cue_path[0] = '\0'; + close(fd); return 0; } break; @@ -270,6 +271,7 @@ int find_first_cue(const char* m3u_path, char* cue_path, size_t max_len) { } } + close(fd); return -EINVAL; } From cae9591c2f493382bd7f1bfd764413fafdf4fa15 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 14 Oct 2013 00:05:07 -0400 Subject: [PATCH 7/7] Missed a spot for closing file handle fd in function get_sha1. --- tools/retrolaunch/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/retrolaunch/main.c b/tools/retrolaunch/main.c index 105d28a1af..12ef76166f 100644 --- a/tools/retrolaunch/main.c +++ b/tools/retrolaunch/main.c @@ -126,6 +126,7 @@ static int get_sha1(const char *path, char *result) } if (!SHA1Result(&sha)) { + close(fd); return -1; }