Re: Add the NULL pointer check in some functions

Nick Gorham <[email protected]> Wed, 19 Nov 2014 09:38:37 +0000
Newsgroups gmane.comp.db.unixodbc.devel
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============0519706020==
Content-Type: multipart/alternative;
	boundary="------------080506060102000301070307"

This is a multi-part message in MIME format.
--------------080506060102000301070307
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit

On 19/11/14 08:41, xiaonan wrote:
> Hi Nick,
>
> At the beginning of the __validate_stmt(), the function will check 
> whether the statement is NULL or not:
> int __validate_stmt( DMHSTMT statement )
> {
> #ifdef FAST_HANDLE_VALIDATE
>
> if ( statement && *(( int * ) statement ) == HSTMT_MAGIC )
> return 1;
> else
> return 0;
>
> #else
> ......
> #endif
> }
> So I think __validate_env(), __validate_dbc() and __validate_desc() 
> should all add this protection. E.g.:
> int __validate_env( DMHENV env )
> {

Yes, thats worth adding. I will do so.

-- 
Nick

--------------080506060102000301070307
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: 7bit

<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 19/11/14 08:41, xiaonan wrote:<br>
    </div>
    <blockquote
      cite="mid:[email protected]"
      type="cite">
      <div
        style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial">
        <div>Hi Nick,</div>
        <div><br>
        </div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>At
          the beginning of the __validate_stmt(), the function will
          check whether the statement is NULL or not:</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span></div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>int
          __validate_stmt( DMHSTMT statement )</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>#ifdef
          FAST_HANDLE_VALIDATE</div>
        <div><br>
        </div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>if
          ( statement &amp;&amp; *(( int * ) statement ) == HSTMT_MAGIC
          )</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>return
          1;</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>else</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>return
          0;</div>
        <div><br>
        </div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>#else</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>......</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>#endif</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span></div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>So
          I think __validate_env(), __validate_dbc() and
          __validate_desc() should all add this protection. E.g.:</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>int
          __validate_env( DMHENV env )</div>
        <div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div>
      </div>
    </blockquote>
    <br>
    Yes, thats worth adding. I will do so.<br>
    <br>
    -- <br>
    Nick<br>
  </body>
</html>

--------------080506060102000301070307--

--===============0519706020==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
unixODBC-dev mailing list
[email protected]
http://mailman.unixodbc.org/mailman/listinfo/unixodbc-dev

--===============0519706020==--