httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/lib apr_cpystrn.c
Date Mon, 26 Jun 2000 23:35:32 GMT
gstein      00/06/26 16:35:29

  Modified:    src/lib/apr/lib apr_cpystrn.c
  Log:
  A string constant was straddling a newline. Badness.
  
  (separate fix by Greg: #if an Apache function call out of existence, and
   optimize the function by computing length once and memcpy'ing)
  
  Submitted by: "Victor J. Orlikowski" <vjo@raleigh.ibm.com>
  Reviewed by: Greg Stein
  
  Revision  Changes    Path
  1.24      +9 -4      apache-2.0/src/lib/apr/lib/apr_cpystrn.c
  
  Index: apr_cpystrn.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/lib/apr_cpystrn.c,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- apr_cpystrn.c	2000/06/22 00:35:57	1.23
  +++ apr_cpystrn.c	2000/06/26 23:35:28	1.24
  @@ -248,12 +248,17 @@
   char *strdup(const char *str)
   {
       char *sdup;
  -    if (!(sdup = (char *) malloc(strlen(str) + 1))) {
  -        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Ouch!
  - Out of memory in our strdup()!");
  +    size_t len = strlen(str) + 1;
  +
  +    if (!(sdup = (char *) malloc(len))) {
  +        /* ### whoops! we can't call Apache logging routines here... */
  +#if 0
  +        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
  +                     "Ouch! Out of memory in our strdup()!");
  +#endif
           return NULL;
       }
  -    sdup = strcpy(sdup, str);
  +    memcpy(sdup, str, len);
   
       return sdup;
   }
  
  
  

Mime
View raw message