[freetds] Bug in dblib CHECK_CONN macro?

Frediano Ziglio freddy77 at gmail.com
Sat Dec 19 05:01:16 EST 2015


2015-12-18 20:06 GMT+00:00 Joshua Lang <joshua.h.lang at gmail.com>:
> It seems that once the TDS socket on a dblib connection becomes invalid,
> the error handling no long er references the connection, even though it
> seems as though it should? Perhaps I'm missing something? This is causing
> subsequent uses of the DBPROCESS pointer to fail (as they should), but the
> resulting error is not correctly associated with the DBPROCESS.
>
> See below for a patch. Note that dbproc is passed instead of NULL to
> dbperror.
>
> diff --git a/include/dblib.h b/include/dblib.h
> index e03ccaa..019c99d 100644
> --- a/include/dblib.h
> +++ b/include/dblib.h
> @@ -199,7 +199,7 @@ extern EHANDLEFUNC _dblib_err_handler;
>  #define DBPERROR_RETURN(x, msg)        if (x) { dbperror(dbproc, (msg),
> 0); return FAIL; }
>  #define DBPERROR_RETURN3(x, msg, a, b, c)      if (x) { dbperror(dbproc,
> (msg), 0, a, b, c); return FAIL; }
>  #define CHECK_CONN(ret) do { CHECK_PARAMETER(dbproc, SYBENULL, (ret)); \
> -       if (IS_TDSDEAD(dbproc->tds_socket)) { dbperror(NULL, SYBEDDNE, 0);
> return (ret); } } while(0)
> +       if (IS_TDSDEAD(dbproc->tds_socket)) { dbperror(dbproc, SYBEDDNE,
> 0); return (ret); } } while(0)
>
>
>  #ifdef __cplusplus


Well spot!

https://github.com/FreeTDS/freetds/commit/420141cc10a8f0110e1c6773d3487c4b085af9a2

(also in 0.95)

Frediano


More information about the FreeTDS mailing list