Skip to content

Commit 5a0f99d

Browse files
committed
Fix use-after-free in lsof_select_process_regex
Set xp to NULL after assigning to CmdRx[i].exp so that CLEAN(xp) in the cleanup path does not free memory that is now owned by CmdRx[i].exp.
1 parent 4713290 commit 5a0f99d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/lsof.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,7 @@ enum lsof_error lsof_select_process_regex(struct lsof_context *ctx, char *x) {
926926
*/
927927
CmdRx[i].mc = 0;
928928
CmdRx[i].exp = xp;
929+
xp = NULL;
929930
NCmdRxU++;
930931

931932
/** Update selection flags for inclusion */

0 commit comments

Comments
 (0)