From 4525ffbd913a6c0027747f3d7dd0d2386fbe1d9f Mon Sep 17 00:00:00 2001 From: James Bursa Date: Tue, 11 Dec 2007 04:06:49 +0000 Subject: Plug a memory leak in ro_plot_path(). svn path=/trunk/netsurf/; revision=3665 --- riscos/plotters.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'riscos') diff --git a/riscos/plotters.c b/riscos/plotters.c index 36518b77b..124774450 100644 --- a/riscos/plotters.c +++ b/riscos/plotters.c @@ -226,7 +226,7 @@ bool ro_plot_path(float *p, unsigned int n, colour fill, float width, static const draw_line_style line_style = { draw_JOIN_MITRED, draw_CAP_BUTT, draw_CAP_BUTT, 0, 0x7fffffff, 0, 0, 0, 0 }; - int *path; + int *path = 0; unsigned int i; os_trfm trfm; os_error *error; @@ -236,13 +236,13 @@ bool ro_plot_path(float *p, unsigned int n, colour fill, float width, if (p[0] != PLOTTER_PATH_MOVE) { LOG(("path doesn't start with a move")); - return false; + goto error; } path = malloc(sizeof *path * (n + 10)); if (!path) { LOG(("out of memory")); - return false; + goto error; } for (i = 0; i < n; ) { @@ -270,7 +270,7 @@ bool ro_plot_path(float *p, unsigned int n, colour fill, float width, i += 7; } else { LOG(("bad path command %f", p[i])); - return false; + goto error; } } path[i] = draw_END_PATH; @@ -289,14 +289,14 @@ bool ro_plot_path(float *p, unsigned int n, colour fill, float width, if (error) { LOG(("xcolourtrans_set_gcol: 0x%x: %s", error->errnum, error->errmess)); - return false; + goto error; } error = xdraw_fill((draw_path *) path, 0, &trfm, 0); if (error) { LOG(("xdraw_stroke: 0x%x: %s", error->errnum, error->errmess)); - return false; + goto error; } } @@ -306,7 +306,7 @@ bool ro_plot_path(float *p, unsigned int n, colour fill, float width, if (error) { LOG(("xcolourtrans_set_gcol: 0x%x: %s", error->errnum, error->errmess)); - return false; + goto error; } error = xdraw_stroke((draw_path *) path, 0, &trfm, 0, @@ -314,11 +314,15 @@ bool ro_plot_path(float *p, unsigned int n, colour fill, float width, if (error) { LOG(("xdraw_stroke: 0x%x: %s", error->errnum, error->errmess)); - return false; + goto error; } } return true; + +error: + free(path); + return false; } -- cgit v1.2.3