]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
nsswitch: Fix memory leak in wbinfo_xids_to_sids()
authorAndreas Schneider <asn@samba.org>
Wed, 22 Oct 2025 07:36:50 +0000 (09:36 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 22 Oct 2025 08:22:30 +0000 (08:22 +0000)
We should not allocate on the NULL context.

=================================================================
==313033==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 376 byte(s) in 1 object(s) allocated from:
    #0 0x7ff48b520b4b  (/lib64/libasan.so.8+0x120b4b) (BuildId: 388ee9ac193f74c177c6f52988d2d0dab110de41)
    #1 0x7ff48bb079d3 in _talloc_realloc ../../lib/talloc/talloc.c:2035
    #2 0x7ff48bb0824c in _talloc_realloc_array ../../lib/talloc/talloc.c:2810
    #3 0x00000021ab91 in wbinfo_xids_to_sids ../../nsswitch/wbinfo.c:1122
    #4 0x00000021ab91 in main ../../nsswitch/wbinfo.c:3065
    #5 0x7ff48842b2fa in __libc_start_call_main (/lib64/libc.so.6+0x2b2fa) (BuildId: 8523b213e7586a93ab00f6dd476418b1e521e62c)
    #6 0x7ffd3dc6866e  ([stack]+0x2066e)

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
nsswitch/wbinfo.c

index 1b3fb41b2d87ba59a88609cce82bddcb8d7f9716..39d03f7bd1bd76f6eb1942ab877cd69155b61b21 100644 (file)
@@ -1119,7 +1119,7 @@ static bool wbinfo_xids_to_sids(const char *arg)
        p = arg;
 
        while (next_token_talloc(frame, &p, &idstr, LIST_SEP)) {
-               xids = talloc_realloc(xids,
+               xids = talloc_realloc(frame,
                                      xids,
                                      struct wbcUnixId,
                                      num_xids + 1);