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:
Guillem Jover 2022-08-23 23:49:34 +02:00
parent f4baceb82c
commit a14612d968

View File

@ -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); \
} \