From 3bb3c9c92d71a284d3d8293f27120e16fbd8d0cf Mon Sep 17 00:00:00 2001 From: "Lv, Qi" Date: Sun, 3 Sep 2023 16:29:35 +0800 Subject: [PATCH] fix a memory leak in `canopen_app_init` --- CANopenNode_STM32/CO_app_STM32.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CANopenNode_STM32/CO_app_STM32.c b/CANopenNode_STM32/CO_app_STM32.c index d73a6d0..e9a5bb5 100644 --- a/CANopenNode_STM32/CO_app_STM32.c +++ b/CANopenNode_STM32/CO_app_STM32.c @@ -63,12 +63,12 @@ canopen_app_init(CANopenNodeSTM32* _canopenNodeSTM32) { canopenNodeSTM32 = _canopenNodeSTM32; #if (CO_CONFIG_STORAGE) & CO_CONFIG_STORAGE_ENABLE - CO_storage_t storage; - CO_storage_entry_t storageEntries[] = {{.addr = &OD_PERSIST_COMM, - .len = sizeof(OD_PERSIST_COMM), - .subIndexOD = 2, - .attr = CO_storage_cmd | CO_storage_restore, - .addrNV = NULL}}; + static CO_storage_t storage; + static CO_storage_entry_t storageEntries[] = {{.addr = &OD_PERSIST_COMM, + .len = sizeof(OD_PERSIST_COMM), + .subIndexOD = 2, + .attr = CO_storage_cmd | CO_storage_restore, + .addrNV = NULL}}; uint8_t storageEntriesCount = sizeof(storageEntries) / sizeof(storageEntries[0]); uint32_t storageInitError = 0; #endif