URL: <http://savannah.gnu.org/bugs/?44464>
Summary: gmk_add_function retains ptr to name it's given Project: make Submitted by: phantal Submitted on: Sat 07 Mar 2015 09:45:42 AM GMT Severity: 3 - Normal Item Group: Bug Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any Component Version: 4.1 Operating System: Any Fixed Release: None Triage Status: None _______________________________________________________ Details: The pointer to the string used to name a function is stored directly instead of being copied when gmk_add_function gets called. This can be a problem if gmk_add_function is called with a temporary / stack variable; here's a few examples of how this could be an issue: {{{ static char* blah( const char*, unsigned int, char ** ) { return NULL; } extern "C" int blah_gmk_setup( const gmk_floc* floc ) { char test[] = "something"; std::string asdf( "something_else" ); gmk_add_function( test, blah, 1, 0, 0 ); gmk_add_function( asdf.c_str(), blah, 1, 0, 0 ); return 1; } }}} Plainly that uses some C++isms, but the issue is the same either way. The 2nd invocation should be fine since the const string ptr will be valid until that call is complete, but since gmk_add_function stores the pointer directly it'll eventually be pointing at garbage data. _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?44464> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make