Skip to content

Commit 9368766

Browse files
committed
CFSTORE - Fix crashed due to uninit data
When the config store is powered down area_0_head is freed, but area_0_len is not set to 0. This causes when cfstore_realloc_ex is called, since on the first allocation it appears that the config store size is decreasing, and therefore the data is not initialized. Since the data is uninitiated various fields such as the reference can have invalid values. On GCC_ARM built with heap stats enabled this manifests as a crash due to an invalid reference count. This patch fixes this problem by setting area_0_len to 0 when the data is freed.
1 parent 3ab3236 commit 9368766

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

features/storage/FEATURE_STORAGE/cfstore/source/configuration_store.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4045,6 +4045,7 @@ static int32_t cfstore_uninitialise(void)
40454045
CFSTORE_FREE(ctx->area_0_head);
40464046
ctx->area_0_head = NULL;
40474047
ctx->area_0_tail = NULL;
4048+
ctx->area_0_len = 0;
40484049
}
40494050
}
40504051
out:

0 commit comments

Comments
 (0)