From 4f655c952bc18625b76f07e81518016cba7eee77 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 27 Mar 2006 02:51:25 +0000 Subject: r14743: Fix coverity bug #227. Possible deref of null pointer in error code path. Jeremy. (This used to be commit 9117713c5ee220331106d291425703aec4d7dd2c) --- source3/utils/net_rpc_samsync.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c index 1faa487e45..b1807bb79b 100644 --- a/source3/utils/net_rpc_samsync.c +++ b/source3/utils/net_rpc_samsync.c @@ -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); -- cgit