c++ - How to assert/test when uninitialised memory is passed to function -
i have situation part of code has been found passed uninitialized memory @ times. looking way in assert when case occurs when running debug-heap. function thrown in places in tracking bugs:
void foo( char* data, int databytes ) { assert( !hasuninitialiseddata(data,databytes) ); //, ... }
i have seen there tools valgrind , run on windows there drmemory. these run external application don't find issue when occurs developer. more importantly these throw thousands of reports qt , other irrelevant functions making things impossible.
i think idea have function search 0xbaadfood within array there whole series of potential hex values , these change per platform. these hex values may valid when integers stored not sure if there more information can obtained form debug-heap.
i interested potential there crt function, library, visual-studio breakpoint, or other helper function doing sort of check. 'feels' there should 1 somewhere already, couldn't find yet if has nice solutions sort of situation appreciated.
edit: should explain better, know debug-heap initialize allocations value in attempt allow detecting uninitialised data. mentioned data being received contains 0xbaadfood values, memory initialized 0xcdcdcdcd third party library allocating data , apparently there multiple magic numbers hence interested if there generalized check hidden somewhere.
the vc++ runtime, @ least in debug builds, initialize heap allocations value. has been same value long can remember. can't, however, remember actual value. quick allocation test , check.
Comments
Post a Comment