Browse Source

Bug 630097 - (cov#12148) NULL dereference in ruvInit()

We need to check if ruv is NULL before dereferencing it.  The
assertion will not help us here in an optimized build, so an
explicit NULL check will keep us from crashing.
Nathan Kinder 15 năm trước cách đây
mục cha
commit
ff41170172
1 tập tin đã thay đổi với 5 bổ sung3 xóa
  1. 5 3
      ldap/servers/plugins/replication/repl5_ruv.c

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

@@ -1443,6 +1443,10 @@ ruvInit (RUV **ruv, int initCount)
 {
 	PR_ASSERT (ruv);
 
+	if (ruv == NULL) {
+		return RUV_NSPR_ERROR;
+	}
+
 	/* allocate new RUV */
 	*ruv = (RUV *)slapi_ch_calloc (1, sizeof (RUV));
 
@@ -1457,9 +1461,7 @@ 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);
-		}
+		dl_free(&(*ruv)->elements);
 		slapi_ch_free((void**)ruv);
 		return RUV_NSPR_ERROR;
 	}