Add the NULL pointer check in some functions

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Add the NULL pointer check in some functions

xiaonan-2
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 )
{
#ifdef FAST_HANDLE_VALIDATE

if ( env && *(( int * ) env ) == HENV_MAGIC )
return 1;
else
return 0;
#else
......
#endif
}

Best Regards
Nan Xiao



_______________________________________________
unixODBC-dev mailing list
[hidden email]
http://mailman.unixodbc.org/mailman/listinfo/unixodbc-dev
Reply | Threaded
Open this post in threaded view
|

Re: Add the NULL pointer check in some functions

Nick Gorham-2
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

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