1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-07-22 10:47:45 +02:00

Fixed memory leak

This commit is contained in:
Anthony Scemama 2021-03-31 01:52:43 +02:00
parent 93b5e48a6b
commit 7642d336d1
2 changed files with 2 additions and 0 deletions

View File

@ -203,6 +203,7 @@ qmckl_context qmckl_context_create() {
const size_t size = 128L; const size_t size = 128L;
qmckl_memory_info_struct * new_array = calloc(size, sizeof(qmckl_memory_info_struct)); qmckl_memory_info_struct * new_array = calloc(size, sizeof(qmckl_memory_info_struct));
if (new_array == NULL) { if (new_array == NULL) {
free(ctx);
return QMCKL_NULL_CONTEXT; return QMCKL_NULL_CONTEXT;
} }
memset( &(new_array[0]), 0, size * sizeof(qmckl_memory_info_struct) ); memset( &(new_array[0]), 0, size * sizeof(qmckl_memory_info_struct) );

View File

@ -126,6 +126,7 @@ void* qmckl_malloc(qmckl_context context, const qmckl_memory_info_struct info) {
sizeof(qmckl_memory_info_struct)); sizeof(qmckl_memory_info_struct));
if (new_array == NULL) { if (new_array == NULL) {
qmckl_unlock(context); qmckl_unlock(context);
free(pointer);
return NULL; return NULL;
} }