<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 6/12/19 10:02 AM, Brian Burkhalter
      wrote:<br>
    </div>
    <blockquote
      cite="mid:69085D8F-42C3-434A-BEB9-D2E694038CE7@oracle.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      Actually, never mind, I am being completely lame here: both
      NET_ThrowNew() and the Windows function LocalFree() are robust to
      a NULL-valued buf so I think we can just remove the n > 0 or
      buf == NULL check altogether.
      <div class=""><br class="">
      </div>
    </blockquote>
    That's true, assuming that you initialize buf = NULL and hopping
    that FormatMessage won't change buf upon failure.<br>
    <br>
    I wish MSDN were a little bit more specific here.<br>
    <br>
    I am fine with<br>
    <br>
    1)<br>
    362         TCHAR *buf = NULL;<br>
    <br>
    2)<br>
    unconditional<br>
     395                    NET_ThrowNew(env, err, buf);<br>
     396                    LocalFree(buf);<br>
    <br>
    With kind regards,<br>
    Ivan<br>
    <br>
    <blockquote
      cite="mid:69085D8F-42C3-434A-BEB9-D2E694038CE7@oracle.com"
      type="cite">
      <div class="">Sorry for the noise: I should have checked this
        first.</div>
      <div class=""><br class="">
      </div>
      <div class="">Thanks,</div>
      <div class=""><br class="">
      </div>
      <div class="">Brian<br class="">
        <div><br class="">
          <blockquote type="cite" class="">
            <div class="">On Jun 12, 2019, at 9:51 AM, Brian Burkhalter
              <<a moz-do-not-send="true"
                href="mailto:brian.burkhalter@oracle.com" class="">brian.burkhalter@oracle.com</a>>
              wrote:</div>
            <br class="Apple-interchange-newline">
            <div class="">
              <div class="" style="caret-color: rgb(0, 0, 0);
                font-family: Helvetica; font-size: 12px; font-style:
                normal; font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;">I am perhaps beating a dead
                horse here, but how about this instead?</div>
              <div class="" style="caret-color: rgb(0, 0, 0);
                font-family: Helvetica; font-size: 12px; font-style:
                normal; font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;"><br class="">
              </div>
              <div class="" style="caret-color: rgb(0, 0, 0);
                font-family: Helvetica; font-size: 12px; font-style:
                normal; font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;">
                <div class="">                if (n > 0) {</div>
                <div class="">                    NET_ThrowNew(env, err,
                  buf);</div>
                <div class="">                    LocalFree(buf);</div>
                <div class="">                } else {</div>
                <div class="">                    NET_ThrowNew(env, err,
                  "FormatMessage failed");</div>
                <div class="">                }</div>
                <div class=""><br class="">
                </div>
                <div class="">After all, an error *did* occur.</div>
              </div>
            </div>
          </blockquote>
        </div>
        <br class="">
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
With kind regards,
Ivan Gerasimov</pre>
  </body>
</html>