[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #44464] gmk_add_function retains ptr to name it's given

From: Brian Vandenberg
Subject: [bug #44464] gmk_add_function retains ptr to name it's given
Date: Sat, 07 Mar 2015 09:45:43 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/40.0.2214.111 Chrome/40.0.2214.111 Safari/537.36


                 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



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:


  Message sent via/by Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]