diff --git a/lib/espMqttClient/src/Packets/Packet.cpp b/lib/espMqttClient/src/Packets/Packet.cpp index 14d241b20..d33a633f1 100644 --- a/lib/espMqttClient/src/Packets/Packet.cpp +++ b/lib/espMqttClient/src/Packets/Packet.cpp @@ -321,7 +321,14 @@ bool Packet::_allocate(size_t remainingLength, bool check) { #if EMC_USE_MEMPOOL _data = reinterpret_cast(_memPool.malloc(_size)); #else - _data = reinterpret_cast(malloc(_size)); +#ifdef EMSESP_STANDALONE + _data = reinterpret_cast(malloc(_size)); +#else + _data = reinterpret_cast(ps_malloc(_size)); + if (!_data) { + _data = reinterpret_cast(malloc(_size)); + } +#endif #endif if (!_data) { _size = 0;