Bug #2752 mysql_free_result cant free results sometimes returned by wrong queries.
Submitted: 12 Feb 2004 9:27 Modified: 16 Feb 2004 15:46
Reporter: qFox Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.0.4-beta OS:Windows (winxp pro)
Assigned to: Dean Ellis CPU Architecture:Any

[12 Feb 2004 9:27] qFox
Description:
sorry to use an old client (4.0.4-beta) with a 4.0.17-nt server
but i searched for the bug but didnt find anything on the subject, so i'll guess the bug still exists.

sometimes (NOT ALWAYS, this appears to be very random!) if you send a faulthy query, the mysql_store_result() returns a odd value ("ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ"). i think its -1, but i'll leave that up to you.
this itself isnt very bad, but the problem comes with mysql_free_result(), this will crash the code if it encounters that value.

like i said, the occurence is very random, i dont know what causes it internally (i'm sure someone does...)

How to repeat:
mysql_real_query() faulthy queries repeatingly
store mysql_store_result() after the query
free that variable with mysql_free_result()

Suggested fix:
hell if i know... make mysqlfreeresult support that value, some better error checking to see if the result variable is useable.
or just dont send wrong queries ;)
[16 Feb 2004 15:46] Dean Ellis
Assuming that by "faulty query" you mean an invalid query, then upon checking the return of mysql_real_query() you should already know that the query did not execute successfully, and you should not be calling mysql_store_result() against that.

Nonetheless, I am unable to repeat this behavior with current releases.