瀏覽代碼

Bug 619122 - fix coverity Defect Type: Resource leaks issues CID 11975 - 12051

https://bugzilla.redhat.com/show_bug.cgi?id=619122
Resolves: bug 619122
Bug description: fix coverify Defect Type: Resource leaks issues CID 12025.
description: The ruvInit() has been modified to release resources if an error occurs.
Noriko Hosoi 15 年之前
父節點
當前提交
92ee0f56c4
共有 1 個文件被更改,包括 5 次插入13 次删除
  1. 5 13
      ldap/servers/plugins/replication/repl5_ruv.c

+ 5 - 13
ldap/servers/plugins/replication/repl5_ruv.c

@@ -1441,21 +1441,9 @@ ruvInit (RUV **ruv, int initCount)
 
 	/* allocate new RUV */
 	*ruv = (RUV *)slapi_ch_calloc (1, sizeof (RUV));
-	if (ruv == NULL)
-	{
-		slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, 
-						"ruvInit: memory allocation failed\n");
-		return RUV_MEMORY_ERROR;
-	}
 
 	/* allocate	elements */
-	(*ruv)->elements = dl_new ();
-	if ((*ruv)->elements == NULL)
-	{
-		slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, 
-						"ruvInit: memory allocation failed\n");
-		return RUV_MEMORY_ERROR;
-	}
+	(*ruv)->elements = dl_new (); /* never returns NULL */
 
 	dl_init ((*ruv)->elements, initCount);
 
@@ -1465,6 +1453,10 @@ ruvInit (RUV **ruv, int initCount)
 	{
 		slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, 
 						"ruvInit: failed to create lock\n");
+		if (*ruv) {
+			dl_free(&(*ruv)->elements);
+		}
+		slapi_ch_free((void**)ruv);
 		return RUV_NSPR_ERROR;
 	}