summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2021-03-10 16:11:29 +0100
committerDaiki Ueno <ueno@gnu.org>2021-04-04 10:20:59 +0200
commit8de3bd90e1d958147331882a51263216b5ea96d2 (patch)
tree79a55066ca03888f1aef823a6544cd4b921af159
parent9bdb7bb60ebddaa8f167e5cfae317dbf202f0e67 (diff)
downloadgnutls-8de3bd90e1d958147331882a51263216b5ea96d2.tar.gz
_gnutls_buffer_resize: account for unused area if AGGRESSIVE_REALLOC
Signed-off-by: Daiki Ueno <ueno@gnu.org>
-rw-r--r--lib/str.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/str.c b/lib/str.c
index 506fe17210..bc20ebb04f 100644
--- a/lib/str.c
+++ b/lib/str.c
@@ -155,12 +155,12 @@ int _gnutls_buffer_resize(gnutls_buffer_st * dest, size_t new_size)
unused = MEMSUB(dest->data, dest->allocd);
dest->allocd =
- gnutls_realloc_fast(dest->allocd, new_size);
+ gnutls_realloc_fast(dest->allocd, new_size + unused);
if (dest->allocd == NULL) {
gnutls_assert();
return GNUTLS_E_MEMORY_ERROR;
}
- dest->max_length = new_size;
+ dest->max_length = new_size + unused;
dest->data = dest->allocd + unused;
return 0;