Merge pull request #771 from JacobBarthelmeh/master

account for static memory IO_POOL free when general memory was used
This commit is contained in:
toddouska
2017-03-03 08:31:55 -08:00
committed by GitHub

View File

@ -539,7 +539,9 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
}
/* case of using fixed IO buffers */
if (mem->flag & WOLFMEM_IO_POOL_FIXED) {
if (mem->flag & WOLFMEM_IO_POOL_FIXED &&
(type == DYNAMIC_TYPE_OUT_BUFFER ||
type == DYNAMIC_TYPE_IN_BUFFER)) {
if (type == DYNAMIC_TYPE_OUT_BUFFER) {
pt = hint->outBuf;
}
@ -547,9 +549,9 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
pt = hint->inBuf;
}
}
else {
/* check if using IO pool flag */
if (mem->flag & WOLFMEM_IO_POOL && pt == NULL &&
if (mem->flag & WOLFMEM_IO_POOL &&
(type == DYNAMIC_TYPE_OUT_BUFFER ||
type == DYNAMIC_TYPE_IN_BUFFER)) {
if (mem->io != NULL) {
@ -570,6 +572,7 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
}
}
}
}
if (pt != NULL) {
mem->inUse += pt->sz;
@ -672,7 +675,7 @@ void wolfSSL_Free(void *ptr, void* heap, int type)
/* fixed IO pools are free'd at the end of SSL lifetime
using FreeFixedIO(WOLFSSL_HEAP* heap, wc_Memory** io) */
}
else if (mem->flag & WOLFMEM_IO_POOL &&
else if (mem->flag & WOLFMEM_IO_POOL && pt->sz == WOLFMEM_IO_SZ &&
(type == DYNAMIC_TYPE_OUT_BUFFER ||
type == DYNAMIC_TYPE_IN_BUFFER)) {
pt->next = mem->io;