heimdal: Pass the correct pointer to realloc when growing a string buffer

The realloc in my_fgetln was trying to grow the pointer to the string
buffer, not the string buffer itself.

In function 'my_fgetln',
    inlined from 'mit_prop_dump' at crypto/heimdal/kdc/mit_dump.c:156:19:
crypto/heimdal/kdc/mit_dump.c:119:13: error: 'realloc' called on unallocated object 'line' [-Werror=free-nonheap-object]
  119 |         n = realloc(buf, *sz + (*sz >> 1));
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
crypto/heimdal/kdc/mit_dump.c: In function 'mit_prop_dump':
crypto/heimdal/kdc/mit_dump.c:139:11: note: declared here
  139 |     char *line = NULL;
      |           ^~~~

Reviewed by:	rmacklem, cy
Fixes:		a93e1b731ae4 ("heimdal-kadmin: Add support for the -f dump option")
Differential Revision:	https://reviews.freebsd.org/D54933
This commit is contained in:
John Baldwin
2026-02-02 12:18:11 -05:00
parent 7f54c65abc
commit 03d8ac948b
+1 -1
View File
@@ -116,7 +116,7 @@ my_fgetln(FILE *f, char **buf, size_t *sz, size_t *len)
return 0;
}
*len += strlen(&(*buf)[*len]); /* *len should be == *sz */
n = realloc(buf, *sz + (*sz >> 1));
n = realloc(*buf, *sz + (*sz >> 1));
if (!n) {
free(*buf);
*buf = NULL;