On 4/14/2013 7:46 AM, Christophe JAILLET wrote: > Le 13/04/2013 02:07, drugg...@apache.org a écrit : >> Author: druggeri >> Date: Sat Apr 13 00:07:44 2013 >> New Revision: 1467523 >> >> URL: http://svn.apache.org/r1467523 >> Log: >> Static var not neccessary here >> >> Modified: >> httpd/httpd/trunk/server/util.c >> >> Modified: httpd/httpd/trunk/server/util.c >> URL: >> http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?rev=1467523&r1=1467522&r2=1467523&view=diff >> ============================================================================== >> >> --- httpd/httpd/trunk/server/util.c (original) >> +++ httpd/httpd/trunk/server/util.c Sat Apr 13 00:07:44 2013 >> @@ -2955,7 +2955,7 @@ AP_DECLARE(char *) ap_get_exec_line(apr_ >> const char *cmd, >> const char * const * argv) >> { >> - static char buf[MAX_STRING_LEN]; >> + char buf[MAX_STRING_LEN]; >> apr_procattr_t *procattr; >> apr_proc_t *proc; >> apr_file_t *fp; > Without the static attribute, gcc gives the following warning: > > util.c: In function 'ap_get_exec_line': > util.c:2997:5: warning: function returns address of local variable > [enabled by default] > > > Either, you should allocate memory another way or change the prototype > of the function. > The best would be IMO to pass a new char* parameter and the length of > this buffer. > > Best regards, > jailletc36
Sorry, yes... somehow I missed adding this in my commit but not in my testing directory: return apr_pstrndup(p, buf, k); Will return a string allocated out of the pool instead. -- Daniel Ruggeri