fix potential memory leaks

Co-authored-by: Lew Rossman <LRossman@cinci.rr.com>
This commit is contained in:
0tkl
2023-08-02 14:12:56 +08:00
parent b860f9b16f
commit 2f63e513f0
3 changed files with 34 additions and 15 deletions

View File

@@ -7,7 +7,7 @@
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
Last Updated: 05/15/2019
Last Updated: 08/02/2023
This module is based code by Steve Hill in Graphics Gems III,
David Kirk (ed.), Academic Press, Boston, MA, 1992
@@ -72,7 +72,11 @@ struct Mempool * mempool_create()
if (mempool == NULL) return NULL;
mempool->first = createMemBlock();
mempool->current = mempool->first;
if (mempool->first == NULL) return NULL;
if (mempool->first == NULL)
{
free(mempool);
return NULL;
}
return mempool;
}