Commit 50584266 authored by Sergio Costas's avatar Sergio Costas

Moved the comparisons into the assignments

parent a35cf175
This diff is collapsed.
......@@ -133,10 +133,10 @@ class Test(unittest.TestCase):
self._generic_test("unitest/test21.c",[ (crusty.crusty.MSG_ERROR,"Using variable '{:s}' at line {:d}, after being freed at line {:d}","param4",6,5) ])
def testAssignFreedVariable(self):
self._generic_test("unitest/test22.c",[ (crusty.crusty.MSG_ERROR,"Using the value of '{:s}' at line {:d} in an assignment, but it was freed at line {:d}","param1",5,4) ])
self._generic_test("unitest/test22.c",[ (crusty.crusty.MSG_ERROR,"Using variable '{:s}' at line {:d}, after being freed at line {:d}","param1",5,4) ])
def testAssignUninitializedVariable(self):
self._generic_test("unitest/test23.c",[ (crusty.crusty.MSG_ERROR,"Using the value of '{:s}' at line {:d} in an assignment, but it is uninitialized","param4",5) ])
self._generic_test("unitest/test23.c",[ (crusty.crusty.MSG_ERROR,"Using uninitialized variable '{:s}' at line {:d}","param4",5) ])
def testAssignNonCrustToCrust(self):
self._generic_test("unitest/test24.c",[ (crusty.crusty.MSG_CRITICAL,"Assigning the non-crust variable '{:s}' to the crust variable '{:s}' at line {:d}","param4","param5",5) ])
......@@ -237,5 +237,8 @@ class Test(unittest.TestCase):
def testAssignFunctionPointerToFunctionName(self):
self._generic_test("unitest/test55.c",[ (crusty.crusty.MSG_CRITICAL,"Trying to assign a value to the function name '{:s}' at line {:d}",'test_function',10) ])
def testComparisonDoesntFreePointer(self):
self._generic_test("unitest/test56.c",[ (crusty.crusty.MSG_ERROR,"Assignment to '{:s}' at line {:d}, which was already assigned at line {:d}","param1",5,3) ])
if __name__ == '__main__':
unittest.main()
typedef __crust_t__ unsigned char *crust_t;
void function(crust_t param1) {
int retval = (param1 == NULL) ? 1 : 0;
param1 = NULL; // ERROR: param1 should still have a valid value, because the comparison doesn't free it
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment