GCC 13 -fanalyzer expects memory that is passed to reallocarray() to
have been allocated with reallocarray() in the first place and not with
malloc().
While this requirement seems to contradict the documentation, the usage
of reallocarray() is better than the current plain malloc() in any case.
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
* just fallback only */
if (stat(path, &st) == 0 && (size_t) st.st_size >= sizeof(struct utmpx)) {
imax = st.st_size / sizeof(struct utmpx);
- ary = xmalloc(imax * sizeof(struct utmpx));
+ ary = xreallocarray(NULL, imax, sizeof(struct utmpx));
}
for (i = 0; ; i++) {
int n, lines = 0, vectors = 8, ret = 0, msgline = -1;
size_t dummy = 0;
- iovec = xmalloc(vectors * sizeof(struct iovec));
+ iovec = xreallocarray(NULL, vectors, sizeof(struct iovec));
while (1) {
buf = NULL;
sz = getline(&buf, &dummy, fp);
char *str = xstrdup(s);
char *key = NULL, *tok;
- env_argv = xmalloc(sizeof(char *) * size);
+ env_argv = xreallocarray(NULL, size, sizeof(char *));
env_argv[0] = _("MORE environment variable"); /* program name */
for (tok = strtok_r(str, delim, &key); tok; tok = strtok_r(NULL, delim, &key)) {
if (size == env_argc) {
argc -= optind;
argv += optind;
- buf = xmalloc(bufsiz * sizeof(wchar_t));
+ buf = xreallocarray(NULL, bufsiz, sizeof(wchar_t));
do {
if (*argv) {