s3-rpcclient: Fix cmd_eventlog_loginfo() null pointer passing.
authorAndreas Schneider <asn@samba.org>
Fri, 21 Dec 2012 14:58:49 +0000 (15:58 +0100)
committerGünther Deschner <gd@samba.org>
Wed, 2 Jan 2013 11:35:37 +0000 (12:35 +0100)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
Found by Coverity.

source3/rpcclient/cmd_eventlog.c

index 8acf4173b74a9b16a41a41b62630ea922ab61580..949e02510b2e3d7c62fbd131b2d1257088dbb4ce 100644 (file)
@@ -510,6 +510,12 @@ static NTSTATUS cmd_eventlog_loginfo(struct rpc_pipe_client *cli,
                return status;
        }
 
+       buffer = talloc_array(mem_ctx, uint8_t, bytes_needed);
+       if (buffer == NULL) {
+               status = NT_STATUS_NO_MEMORY;
+               goto done;
+       }
+
        status = dcerpc_eventlog_GetLogInformation(b, mem_ctx,
                                                   &handle,
                                                   0, /* level */
@@ -526,8 +532,8 @@ static NTSTATUS cmd_eventlog_loginfo(struct rpc_pipe_client *cli,
        }
 
        buf_size = bytes_needed;
-       buffer = talloc_array(mem_ctx, uint8_t, bytes_needed);
-       if (!buffer) {
+       buffer = talloc_realloc(mem_ctx, buffer, uint8_t, bytes_needed);
+       if (buffer == NULL) {
                status = NT_STATUS_NO_MEMORY;
                goto done;
        }