FUM.GEN.MIGHTFreeing unallocated memory possibleIf unallocated memory is freed, results can be unpredictable. The FUM.GEN.MIGHT checker finds possible deallocation functions that are invoked with an uninitialized pointer. Vulnerability and riskWhen free() is called on an invalid pointer, it can cause corruption of a program's memory, resulting in program crash, and possibly creating a vulnerability that an attacker can exploit. Mitigation and preventionTo avoid freeing non-heap memory, make sure that you:
Vulnerable code example1 main(){ 2 char * x = 1; 3 if (a) x= malloc(1); 4 free(x); 5 } Klocwork produces an issue report at line 4 indicating that the memory referenced by 'x' and assigned on line 2 may be freed incorrectly at line 4, if the condition at line 3 is false. Freeing unallocated memory can cause an application to crash, and possibly result in vulnerability to attack. Related checkersExternal guidanceExtensionThis checker can be extended through the Klocwork knowledge base. See Tuning C/C++ analysis for more information. |