pichon julien writes:
 > Hello everyone,
 > 
 > I issue a call to db_conn_query without calling before db_conn_connect,
 > and this result in a crash of the lib.
 > 
 > So what do you think about the following patch ?
 > 

Hi Julien, hi Florian,

thanks for reporting this problem and for providing patches. However,
I believe both patches cure a symptom rather than the cause of the
problem. If I understand the OP's problem correctly, the crash occurs
after using the library incorrectly. We should try to make this kind
of "abuse" impossible, rather than fixing each single problem that
might result from improper use in each single driver. In this case, we
should make it impossible to run queries and do other things on a Conn
structure without having a proper connection in the first
place. E.g. dbi_conn_query() has the following check in place:

if (!conn) return 0;

This just checks wether a connection structure was passed at all, not
whether it represents an open connection. I'd suggest to add another
check to dbi_conn_query() and all similar functions:

if (!conn || !(conn->connection)) return 0;

Only then we should inspect each driver for possible crashes if an
opened connection is no longer available (e.g. server went down).

What do you think?

regards,
Markus


-- 
Markus Hoenicka
http://www.mhoenicka.de
AQ score 38

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Libdbi-drivers-devel mailing list
Libdbi-drivers-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-drivers-devel

Reply via email to