nsswitch/libwbclient: clang Fix Potential leak of memory
authorNoel Power <noel.power@suse.com>
Mon, 8 Jul 2019 12:12:59 +0000 (12:12 +0000)
committerGary Lockyer <gary@samba.org>
Thu, 11 Jul 2019 04:08:13 +0000 (04:08 +0000)
Fixes:

nsswitch/libwbclient/wbc_sid.c:848:2: warning: Potential leak of memory pointed to by 'extra_data'
        free(extra_data);
        ^
1 warning generated.
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
nsswitch/libwbclient/wbc_sid.c

index cec7b51..aab96cf 100644 (file)
@@ -792,12 +792,14 @@ wbcErr wbcCtxGetSidAliases(struct wbcContext *ctx,
                sid_len = wbcSidToStringBuf(&sids[i], sid_str, sizeof(sid_str));
 
                if (buflen < extra_data_len + sid_len + 2) {
+                       char * tmp_data = NULL;
                        buflen *= 2;
-                       extra_data = (char *)realloc(extra_data, buflen);
-                       if (!extra_data) {
+                       tmp_data = (char *)realloc(extra_data, buflen);
+                       if (!tmp_data) {
                                wbc_status = WBC_ERR_NO_MEMORY;
                                BAIL_ON_WBC_ERROR(wbc_status);
                        }
+                       extra_data = tmp_data;
                }
 
                strncpy(&extra_data[extra_data_len], sid_str,