r16601: Klocwork #2038. Fix memleak on error path.
authorJeremy Allison <jra@samba.org>
Wed, 28 Jun 2006 02:12:53 +0000 (02:12 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:19:02 +0000 (11:19 -0500)
Jeremy.
(This used to be commit 934dddb2fa9fb60a87c0b0be81db97f2b59c7cb0)

source3/rpc_parse/parse_eventlog.c

index 5e28a4aba5dd4b671b4eea03f394b94c71e5a03f..4aff9734eed9a0230ebd4025c4dde1ac864836f6 100644 (file)
@@ -353,18 +353,18 @@ BOOL eventlog_io_r_read_eventlog(const char *desc,
 
        /* Now pad with whitespace until the end of the response buffer */
 
-       r_u->end_of_entries_padding =
-               SMB_CALLOC_ARRAY(uint8,
-                                q_u->max_read_size - r_u->num_bytes_in_resp);
+       if (q_u->max_read_size - r_u->num_bytes_in_resp) {
+               r_u->end_of_entries_padding = SMB_CALLOC_ARRAY(uint8, q_u->max_read_size - r_u->num_bytes_in_resp);
 
-       if(!(prs_uint8s(False, "end of entries padding", ps, 
-               depth, r_u->end_of_entries_padding,
-               (q_u->max_read_size - r_u->num_bytes_in_resp))))
-       {
-               return False;
-       }
+               if(!(prs_uint8s(False, "end of entries padding", ps, 
+                               depth, r_u->end_of_entries_padding,
+                               (q_u->max_read_size - r_u->num_bytes_in_resp)))) {
+                       free(r_u->end_of_entries_padding);
+                       return False;
+               }
 
-       free(r_u->end_of_entries_padding);
+               free(r_u->end_of_entries_padding);
+       }
 
        /* We had better be DWORD aligned here */