r14743: Fix coverity bug #227. Possible deref of null pointer
authorJeremy Allison <jra@samba.org>
Mon, 27 Mar 2006 02:51:25 +0000 (02:51 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:15:45 +0000 (11:15 -0500)
in error code path.
Jeremy.
(This used to be commit 9117713c5ee220331106d291425703aec4d7dd2c)

source3/utils/net_rpc_samsync.c

index 1faa487e45070f1a01ef82b8951240f4e707ed6e..b1807bb79b1c4517c71bd56cf505af888c8f79c5 100644 (file)
@@ -1982,22 +1982,27 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd,
 
   done:
        /* Close and delete the ldif files */
-       if (add_file)
+       if (add_file) {
                fclose(add_file);
-       if (strcmp(add_name, add_template) && (unlink(add_name))) {
+       }
+
+       if ((add_name != NULL) && strcmp(add_name, add_template) && (unlink(add_name))) {
                DEBUG(1,("unlink(%s) failed, error was (%s)\n",
                         add_name, strerror(errno)));
        }
 
-       if (mod_file)
+       if (mod_file) {
                fclose(mod_file);
-       if (strcmp(mod_name, mod_template) && (unlink(mod_name))) {
+       }
+
+       if ((mod_name != NULL) && strcmp(mod_name, mod_template) && (unlink(mod_name))) {
                DEBUG(1,("unlink(%s) failed, error was (%s)\n",
                         mod_name, strerror(errno)));
        }
        
-       if (ldif_file && (ldif_file != stdout))
+       if (ldif_file && (ldif_file != stdout)) {
                fclose(ldif_file);
+       }
 
        /* Deallocate memory for the mapping arrays */
        SAFE_FREE(groupmap);