title: Segmentation fault in va_args parsing
body: <p>Why does the code below gives <code>EXC_BAD_ACCESS, could not access memory</code>?</p>
  
  <pre><code>int combine_strings(char **outputStr,...)
  {
      va_list ap;
      char *s, *out=0;
      int len=0;
  
      va_start(ap,outputStr);
      while(s=va_arg(ap,char *))
      {
        len+=strlen(s);
      }
      va_end(ap);
  
  
      if(!(out=malloc(len+1)))
          exit(1);
  
      *outputStr=out;
  
      va_start(ap,outputStr);
      while(s=va_arg(ap,char *))
      {
        len=strlen(s);
        memcpy(out,s,len);
        out+=len;
      }
      va_end(ap);
  
      *out=0;
  
      return 0;
  }
  </code></pre>