title: core dump when calling vsnprintf
body: <p>i am on ubuntu 12.04, with uname -a:
  Linux lu057801 3.2.0-31-generic #50-Ubuntu SMP Fri Sep 7 16:16:45 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux</p>
  
  <p>g++ --version:
  Linux lu057801 3.2.0-31-generic #50-Ubuntu SMP Fri Sep 7 16:16:45 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux</p>
  
  <p>I get a core dump in a call to vsnprintf. The following is the entire code that produces the issue:</p>
  
  <pre><code>// compile: g++ -g -o test vsnprintf_test.c
  
  #include &lt;stdarg.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string&gt;
  
  void vout(char *string, char *fmt, ...);
  char fmt1 [] = "%s  %s  %s\n";
  
  size_t snprintf_1(char* buffer, const size_t bufSize, const char* format, ...);
  size_t vsnprintf_1(char* buffer, const size_t bufSize, const char* format, va_list args);
  
  int main(void)
  {
    char * format = "%s";
    char buffer[] = "/var/tmp\0"; //char * buffer = "/var/tmp\0";
    int bufSize=sizeof(buffer); //int bufSize=11;
    snprintf_1(buffer, bufSize, format);
  }
  
  
  size_t snprintf_1(char* buffer, const size_t bufSize, const char* format, ...)
  {
      va_list args;
      va_start(args, format);
      size_t rc = vsnprintf_1(buffer, bufSize, format, args);
      va_end(args);
      return rc;
  }
  
  
  size_t vsnprintf_1(char* buffer, const size_t bufSize, const char* format, va_list args)
  {
      int rc = 0;
      rc = vsnprintf(buffer, bufSize, format, args);
  }
  </code></pre>
  
  <p>Compiling as: g++ -g -o test vsnprintf_test.c and running will give me the following backtrace:</p>
  
  <pre><code>(gdb) run
  Starting program: /home/mafunk/software/MattsSnippets/test 
  
  Program received signal SIGSEGV, Segmentation fault.
  _IO_vsnprintf (string=0x400738 "/var/tmp", maxlen=&lt;optimized out&gt;, format=0x400730 "%s", args=0x7fffffffe0b0) at vsnprintf.c:118
  118     vsnprintf.c: No such file or directory.
  (gdb) bt
  #0  _IO_vsnprintf (string=0x40072f "/var/tmp", maxlen=&lt;optimized out&gt;, format=0x40072c "%s", args=0x7fffffffe0b0) at vsnprintf.c:118
  #1  0x0000000000400639 in vsnprintf_1 (buffer=0x40072f "/var/tmp", bufSize=11, format=0x40072c "%s", args=0x7fffffffe0b0)
  at vsnprintf_test.c:36
  #2  0x00000000004005f2 in snprintf_1 (buffer=0x40072f "/var/tmp", bufSize=11, format=0x40072c "%s") at vsnprintf_test.c:27
  #3  0x0000000000400541 in main () at vsnprintf_test.c:19
  </code></pre>
  
  <p>I guess i am not sure why this is happening. Any help would be greatly appreciated.</p>