ソースを参照

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 年 前
コミット
ff41170172
1 ファイル変更5 行追加3 行削除
  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;
 	}