clibs / cmocka

An elegant unit testing framework for C with support for mock objects.
Apache License 2.0
227 stars 55 forks source link

Segmentation fault on freeing memory allocated by strdup #17

Closed raju2b closed 2 years ago

raju2b commented 4 years ago

While checking memory leaks, buffer overflows using test_free, test_malloc, etc getting segmentation fault in the following case.

But when i have replaced strdup with custom strdup to do the same, its working perfectly, No SEG-FAULT been observed. It seems Cmocka is not tracking the memory block allocated by the strdup.

Work-Around:

Is there any mocking i missed or is it not yet supported by Cmocka ?

MarkSymsCtx commented 3 years ago

Just hit this issue myself. I sort of understand why it happens (as the allocation is done inside a separate shared library) but it doesn't make it any less irritating.