mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-01-08 11:02:24 +01:00
setmode: Dot not use saveset after free
While we are only doing a pointer difference and not dereferencing it, it's easier and more correct to do the pointer difference before passing it to reallocarray(). Warned-by: gcc
This commit is contained in:
parent
f4baceb82c
commit
a14612d968
@ -36,6 +36,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
@ -144,12 +145,13 @@ common: if (set->cmd2 & CMD2_CLR) {
|
||||
|
||||
#define ADDCMD(a, b, c, d) do { \
|
||||
if (set >= endset) { \
|
||||
ptrdiff_t setdiff = set - saveset; \
|
||||
BITCMD *newset; \
|
||||
setlen += SET_LEN_INCR; \
|
||||
newset = reallocarray(saveset, setlen, sizeof(BITCMD)); \
|
||||
if (newset == NULL) \
|
||||
goto out; \
|
||||
set = newset + (set - saveset); \
|
||||
set = newset + setdiff; \
|
||||
saveset = newset; \
|
||||
endset = newset + (setlen - 2); \
|
||||
} \
|
||||
|
Loading…
Reference in New Issue
Block a user