Skip to content

Commit

Permalink
Fix incorrect free in conn_sock
Browse files Browse the repository at this point in the history
Earlier commit freed socket_parent_dir()'s result which is correct in
the case it returns a path from g_build_filename, but when it returns
opt_bundle_path the string should not be freed.

Make the function always return an allocated string that can be freed

Fixes: #475
Fixes: fad6bac ("fix some issues flagged by SAST scan")
Signed-off-by: Dominique Martinet <[email protected]>
  • Loading branch information
martinetd committed Dec 15, 2023
1 parent 3a9715d commit 8557c11
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/conn_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ char *socket_parent_dir(gboolean use_full_attach_path, size_t desired_len)
{
/* if we're to use the full path, ignore the socket path and only use the bundle_path */
if (use_full_attach_path)
return opt_bundle_path;
return strdup(opt_bundle_path);

char *base_path = g_build_filename(opt_socket_path, opt_cuuid, NULL);

Expand Down

0 comments on commit 8557c11

Please sign in to comment.