lib/base: Correct realloc() paramters, to allocate one more byte, not 1 byte

The entry condition here is p == pend so this is really just 1 + p - p, eg just 1.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Andrew Bartlett
2022-10-28 15:04:09 +13:00
committed by Jeffrey Altman
parent 7b75136113
commit 2c8be80a25

View File

@@ -962,7 +962,12 @@ parse_string(struct parse_ctx *ctx)
/* NUL-terminate for rk_base64_decode() and plain paranoia */
if (p0 != NULL && p == pend) {
char *tmp = realloc(p0, 1 + pend - p);
/*
* Work out how far p is into p0 to re-esablish p after
* the realloc()
*/
size_t p0_to_pend_len = (pend - p0);
char *tmp = realloc(p0, 1 + p0_to_pend_len);
if (tmp == NULL) {
ctx->error = heim_error_create_enomem();