[libcroco/wip/fmuellner/coverage-fixes: 2/10] num: Don't leak duped num objects on failure
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libcroco/wip/fmuellner/coverage-fixes: 2/10] num: Don't leak duped num objects on failure
- Date: Tue, 19 Feb 2019 08:09:02 +0000 (UTC)
commit 71e62c2cfbca29ba400c53dbb5da00f35c230731
Author: Florian Müllner <fmuellner gnome org>
Date: Tue Feb 19 00:04:59 2019 +0100
num: Don't leak duped num objects on failure
cr_num_dup() 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
src/cr-num.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/src/cr-num.c b/src/cr-num.c
index d5dbd5f..8b0cc42 100644
--- a/src/cr-num.c
+++ b/src/cr-num.c
@@ -245,7 +245,8 @@ cr_num_dup (CRNum const * a_this)
g_return_val_if_fail (result, NULL);
status = cr_num_copy (result, a_this);
- g_return_val_if_fail (status == CR_OK, NULL);
+ if (status != CR_OK)
+ g_clear_pointer (&result, cr_num_destroy);
return result;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]