From 9c321dfbf0f63a2070013dd1b58bdee37f5ac4aa Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 28 Jan 2015 15:05:14 +0100 Subject: [PATCH] libfdisk: fix possible mem leak [coverity scan] Signed-off-by: Karel Zak --- libfdisk/src/context.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c index ef8b30b047..84867b0abe 100644 --- a/libfdisk/src/context.c +++ b/libfdisk/src/context.c @@ -149,8 +149,11 @@ struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent, fdisk_ref_context(parent); cxt->parent = parent; - if (init_nested_from_parent(cxt, 1) != 0) + if (init_nested_from_parent(cxt, 1) != 0) { + cxt->parent = NULL; + fdisk_unref_context(cxt); return NULL; + } if (name) { if (strcasecmp(name, "bsd") == 0) -- 2.47.2