[sr-dev] git:master: db_mysql: fix segfault when recursive queries are made

Richard Fuchs rfuchs at sipwise.com
Mon Apr 29 15:01:27 CEST 2013


Hi,

On 04/29/13 07:11, Daniel-Constantin Mierla wrote:
> Hello,
> 
> On 4/10/13 3:36 PM, Richard Fuchs wrote:
>> -int db_mysql_free_result(db1_con_t* _h, db1_res_t* _r);
>> +int db_mysql_free_result(const db1_con_t* _h, db1_res_t* _r);
> the change to the prototype of the above function is now throwing
> compilation warning:
> 
> km_db_mysql.c: In function ‘db_mysql_bind_api’:
> km_db_mysql.c:109: warning: assignment from incompatible pointer type
> 
> Do you need the const specifier? If yes, the DB API and probably the
> other database drivers need to be updated.

The const is needed because db_mysql_free_result is called from other
functions which have the db1_con_t object declared as const. Removing
the const from the prototype would trigger warnings elsewhere.

The idea is that the driver-specific result set should really be stored
in the db1_res_t object, and not in db1_con_t as the other drivers do it
now (which was causing the segfault). Therefore, ->free_result really
has no reason to modify the db1_con_t object, which warrants the const
modifier. Preferably the other drivers should be updated to follow the
same reasoning, after which the const can be put into db_func_t, but I
don't have enough experience with them to do it myself.

Alternatively, the const could probably be removed from this and a few
other function prototypes, or maybe a wrapper function could be used.

cheers

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20130429/a920f7a2/attachment.pgp>


More information about the sr-dev mailing list