summaryrefslogtreecommitdiff
path: root/content/handlers
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2017-08-29 11:55:46 +0100
committerMichael Drake <michael.drake@codethink.co.uk>2017-08-29 11:55:46 +0100
commita9d18a8efd2ec114b1c08fc551a1347fd5befced (patch)
tree2a0e46ab4a8766fa64249fb5926ed18f2cce82a2 /content/handlers
parent41f30992aa92308a93c46fd8bdd80971e6e5e7e0 (diff)
downloadnetsurf-a9d18a8efd2ec114b1c08fc551a1347fd5befced.tar.gz
netsurf-a9d18a8efd2ec114b1c08fc551a1347fd5befced.tar.bz2
Sprite content handler: Fix leaked rosprite_mem_context on rosprite_load error.
Diffstat (limited to 'content/handlers')
-rw-r--r--content/handlers/image/nssprite.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/content/handlers/image/nssprite.c b/content/handlers/image/nssprite.c
index 530c95385..651714744 100644
--- a/content/handlers/image/nssprite.c
+++ b/content/handlers/image/nssprite.c
@@ -49,13 +49,13 @@ typedef struct nssprite_content {
rosprite_error err = x; \
if (err == ROSPRITE_EOF) { \
LOG("Got ROSPRITE_EOF when loading sprite file"); \
- return false; \
+ goto ro_sprite_error; \
} else if (err == ROSPRITE_BADMODE) { \
LOG("Got ROSPRITE_BADMODE when loading sprite file"); \
- return false; \
+ goto ro_sprite_error; \
} else if (err == ROSPRITE_OK) { \
} else { \
- return false; \
+ goto ro_sprite_error; \
} \
} while(0)
@@ -96,7 +96,7 @@ static bool nssprite_convert(struct content *c)
{
nssprite_content *nssprite = (nssprite_content *) c;
- struct rosprite_mem_context* ctx;
+ struct rosprite_mem_context* ctx = NULL;
const char *data;
unsigned long size;
@@ -160,6 +160,13 @@ static bool nssprite_convert(struct content *c)
content_set_status(c, ""); /* Done: update status bar */
return true;
+
+ro_sprite_error:
+ if (ctx != NULL) {
+ rosprite_destroy_mem_context(ctx);
+ }
+
+ return false;
}