title: vsprintf_s() does not work when va_list has length set by local variable
body: <p>I have a utility C function that works correctly:</p>
  
  <pre><code>void UtilDisplayMessage(char* strCaption, char* strMessageFormat, int iArgCount, ...)
  {
      // Initialize the variable arg list
      va_list lstArgs;
      va_start(lstArgs, iArgCount);
  
      // Format the message
      vsprintf_s(g_strMessage, UTIL_DEF_MESSAGE_SIZE, strMessageFormat, lstArgs);
  
      // Destroy the variable arg list
      va_end(lstArgs);
  
      // Use formatted string here...
  }
  </code></pre>
  
  <p>But I would like to remove the 'iArgCount' parameter and so I've made a test function that looks like this:</p>
  
  <pre><code>void UtilDisplayMessageEasy(char* strCaption, char* strMessageFormat, ...)
  {
      // Initialize the variable arg list
      va_list lstArgs;
  
      int iParamCount = 1;
      va_start(lstArgs, iParamCount);
  
      // Format the message
      vsprintf_s(g_strMessage, UTIL_DEF_MESSAGE_SIZE, strMessageFormat, lstArgs);
  
      // Destroy the variable arg list
      va_end(lstArgs);
  
      // Use formatted string here...
  }
  </code></pre>
  
  <p>But I get bogus results if I pass in an integer value with this call:</p>
  
  <pre><code>UtilDisplayMessageEasy("TEST", "The value is %i.", 1);
  </code></pre>
  
  <p>And I get an Access Violation Exception when I pass in a string with this call:</p>
  
  <pre><code>UtilDisplayMessageEasy("TEST", "This is only a %s.", "TEST");
  </code></pre>
  
  <p>Yet, it works fine if I call my original function like so:</p>
  
  <pre><code>UtilDisplayMessage("TEST", "This is only a %s.", 1, "TEST");
  </code></pre>
  
  <p>Is there really such a fundamental difference on whether I pass in an argument parameter or a local parameter into va_start()?</p>
  
  <p>Also I'm aware that variable parameters are not very safe and should used with care, but surely something this innocuous shouldn't set the alarms blaring.</p>
  
  <p>Thank you for any input you might have regarding this issue.</p>