Skip to content

Commit

Permalink
Merge pull request #988 from UncleGrumpy/stm32_mem_bug
Browse files Browse the repository at this point in the history
Fix missing memory allocation check in STM32 platorm

Adds memory allocation check for the `STM32PlatformData` struct before use.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
  • Loading branch information
bettio committed Dec 20, 2023
2 parents fe7514b + fb230d0 commit d2f4a8d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/platforms/stm32/src/lib/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ bool sys_unlock_pin(GlobalContext *glb, uint32_t gpio_bank, uint16_t pin_num)
void sys_init_platform(GlobalContext *glb)
{
struct STM32PlatformData *platform = malloc(sizeof(struct STM32PlatformData));
if (IS_NULL_PTR(platform)) {
AVM_LOGE(TAG, "Out of memory!");
AVM_ABORT();
}
glb->platform_data = platform;
list_init(&platform->locked_pins);
}
Expand Down

0 comments on commit d2f4a8d

Please sign in to comment.