GoogleCloudPlatform / iot-device-sdk-embedded-c

Cloud IoT Device SDK for Connectivity to IoT Core.
Other
247 stars 83 forks source link

malloc(0) issue #92

Open GKNSTM opened 4 years ago

GKNSTM commented 4 years ago

I'm using Google IoT device SDK on an STM32 board (STM32F769I-Discovery) with FreeRTOS and compiling with IAR EWARM.

In two cases during run-time the IoT device SDK code requests zero size memory allocations (equivalent to malloc(0)).

Would it be possible to avoid that ?

This can cause some problems when using memory allocation libraries that return NULL when 0 byte requested for memory allocation. When using FreeRTOS there's an option that triggers an assert when pvPortMalloc() returns NULL.

The two malloc(0) cases are:

Both cases trigger an assert() if we use libraries that check if malloc() returns NULL.

Can it be avoided ?

Thanks

Guillaume