summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Müllner <fmuellner@gnome.org>2019-02-19 00:00:59 +0100
committerFlorian Müllner <fmuellner@gnome.org>2019-02-19 02:00:24 +0100
commit034d7417994f8f8e55f52fa4887b4cd8bba2665e (patch)
tree6d3582f58d285343f6bca97965ee0fed3b23b6cf
parenta637ae6569da36ce62b68a9b9db57d30eb094d04 (diff)
downloadlibcroco-034d7417994f8f8e55f52fa4887b4cd8bba2665e.tar.gz
parser: Don't leak new parser objects on failure
cr_parser_new() may fail and return NULL. The previously allocated memory should be freed in that case. Spotted by covscan. https://gitlab.gnome.org/GNOME/libcroco/merge_requests/1
-rw-r--r--src/cr-parser.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/cr-parser.c b/src/cr-parser.c
index 3899a47..44043b7 100644
--- a/src/cr-parser.c
+++ b/src/cr-parser.c
@@ -2761,6 +2761,8 @@ cr_parser_new (CRTknzr * a_tknzr)
if (a_tknzr) {
status = cr_parser_set_tknzr (result, a_tknzr);
+ if (status != CR_OK)
+ cr_parser_destroy (result);
}
g_return_val_if_fail (status == CR_OK, NULL);