summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2018-05-18 09:56:16 +0100
committerVincent Sanders <vince@kyllikki.org>2018-05-18 10:02:03 +0100
commit7c3da95a07f0d21860e6803567b0603127c517c1 (patch)
tree531aba226bee2282061d6adf90b70aaadbeb77ee
parent216fb88f58227f94e87d9e9926b599161a8e65bb (diff)
downloadnetsurf-7c3da95a07f0d21860e6803567b0603127c517c1.tar.gz
netsurf-7c3da95a07f0d21860e6803567b0603127c517c1.tar.bz2
Resolve resource leak on error (coverity issue 1390560)
-rw-r--r--utils/messages.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/utils/messages.c b/utils/messages.c
index e1e61201f..2e22cc731 100644
--- a/utils/messages.c
+++ b/utils/messages.c
@@ -57,16 +57,16 @@ static nserror messages_load_ctx(const char *path, struct hash_table **ctx)
{
struct hash_table *nctx; /* new context */
nserror res;
-
- if (*ctx == NULL) {
- nctx = hash_create(HASH_SIZE);
- } else {
+
+ if (*ctx != NULL) {
/**
* \note The passed hash is not copied here so this
* updates in place.
*/
- nctx = *ctx;
+ return hash_add_file(*ctx, path);
}
+
+ nctx = hash_create(HASH_SIZE);
if (nctx == NULL) {
NSLOG(netsurf, INFO,
"Unable to create hash table for messages file %s",
@@ -74,10 +74,11 @@ static nserror messages_load_ctx(const char *path, struct hash_table **ctx)
return NSERROR_NOMEM;
}
-
res = hash_add_file(nctx, path);
if (res == NSERROR_OK) {
*ctx = nctx;
+ } else {
+ hash_destroy(nctx);
}
return res;
@@ -337,4 +338,3 @@ void messages_destroy(void)
messages_destroy_ctx(messages_hash);
messages_hash = NULL;
}
-