kill: Fix free() with bad pointer on SIG-prefixed signal-name
kill -l SIGHUP (or any other signal-name prefixed with "SIG") would cause free() to be called with a bad pointer instead of a pointer to what was allocated. Fix this and add test-case.
This commit is contained in:
parent
e02d9f554d
commit
95ed10ff43
@ -263,7 +263,7 @@ char *strtosig(const char *restrict s)
|
||||
}
|
||||
}
|
||||
}
|
||||
free(p);
|
||||
free(copy);
|
||||
return converted;
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,10 @@ set test "kill convert signal name to number"
|
||||
spawn $kill -lHUP
|
||||
expect_pass "$test" "^1\\s*"
|
||||
|
||||
set test "kill convert SIG-prefixed signal name to number"
|
||||
spawn $kill -lSIGHUP
|
||||
expect_pass "$test" "^1\\s*$"
|
||||
|
||||
set test "kill convert signal number to name"
|
||||
spawn $kill -l 1
|
||||
expect_pass "$test" "^HUP\\s*"
|
||||
|
Loading…
Reference in New Issue
Block a user