Skip to content

Commit 56f2e28

Browse files
committed
fixup! unix-socket: avoid leak when initialization fails
This downstream fix changed `return -1` to `goto fail` in `unix_stream_connect()` so that `unix_sockaddr_cleanup()` would run even when `unix_sockaddr_init()` failed, avoiding a memory leak of `ctx->orig_dir`. Upstream fixed the same leak more surgically in c5fe29f (unix-socket: fix memory leak when chdir(3p) fails, 2025-01-30) by having `unix_sockaddr_init()` itself call `FREE_AND_NULL()` on `ctx->orig_dir` before returning -1. With that fix in v2.54.0, the caller's `goto fail` path would only call `unix_sockaddr_cleanup()` as a no-op (since `orig_dir` is already NULL), making the downstream patch redundant. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 39ba52a commit 56f2e28

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

unix-socket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int unix_stream_connect(const char *path, int disallow_chdir)
8484
struct unix_sockaddr_context ctx;
8585

8686
if (unix_sockaddr_init(&sa, path, &ctx, disallow_chdir) < 0)
87-
goto fail;
87+
return -1;
8888
fd = socket(AF_UNIX, SOCK_STREAM, 0);
8989
if (fd < 0)
9090
goto fail;

0 commit comments

Comments
 (0)