-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Our Application contains several screens, of which some contain keypads.
During internal testing, we received feedback that the entering and exiting a screen with a keypad an arbitrary number of times led to a crash (As described by the tester, in reality it was entering the TLB Refill Exception handler).
While debugging this fault, we noticed that immediately before entering the exception handler there were calls being returned a NULL pointer from LE_MALLOC.
After digging into the memory management inside the library, we eventually discovered that while idle there was no change to the capacity of fixedHeap[2], though every time we entered and exited a screen with a keypad, the capacity would be reduced but never recovered. Looking at the callstack, we discovered that it LE_MALLOCs for every row.
gfx/middleware/legato/library/src/gfx/legato/widget/keypad/legato_widget_keypad.c
Lines 90 to 95 in a65f134
| for(r = 0; r < rows; ++r) | |
| { | |
| newCells[r] = LE_MALLOC(cols * sizeof(leKeyPadCell)); | |
| memset(newCells[r], 0, cols * sizeof(leKeyPadCell)); | |
| } |
Although the destructor only LE_FREEs _this->cells
gfx/middleware/legato/library/src/gfx/legato/widget/keypad/legato_widget_keypad.c
Lines 319 to 324 in a65f134
| static void destructor(leKeyPadWidget* _this) | |
| { | |
| LE_FREE(_this->cells); | |
| _leWidget_Destructor((leWidget*)_this); | |
| } |
In order to get around this for our application, we have amended the destructor as follows
static void destructor(leKeyPadWidget* _this)
{
+ for (int r = 0; r < _this->rows; ++r)
+ {
+ LE_FREE(_this->cells[r]);
+ }
LE_FREE(_this->cells);
_leWidget_Destructor((leWidget*)_this);
}This has resolved the issue for us. Hopefully this can be reproduced and fixed for future versions of the GFX library.