[sheepdog] [PATCH v2 2/2] sheep/kv: fix potential memory leak

Robin Dong robin.k.dong at gmail.com
Thu Jan 2 08:51:01 CET 2014


From: Robin Dong <sanbai at taobao.com>

We use 'goto out' in kv_create_object() to avoid memory leak for 'onode'.

Signed-off-by: Robin Dong <sanbai at taobao.com>
---
 sheep/http/kv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sheep/http/kv.c b/sheep/http/kv.c
index 31c9889..dd5ca56 100644
--- a/sheep/http/kv.c
+++ b/sheep/http/kv.c
@@ -1027,7 +1027,7 @@ int kv_create_object(struct http_request *req, const char *account,
 	snprintf(vdi_name, SD_MAX_VDI_LEN, "%s/%s/allocator", account, bucket);
 	ret = sd_lookup_vdi(vdi_name, &data_vid);
 	if (ret != SD_RES_SUCCESS)
-		return ret;
+		goto out;
 
 	memset(onode, 0, sizeof(*onode));
 	pstrcpy(onode->name, sizeof(onode->name), name);
-- 
1.7.12.4




More information about the sheepdog mailing list