Quantcast
Channel: MySQL Forums - Connector/C++
Viewing all articles
Browse latest Browse all 527

C++ Connector/Corruption when using Prepared Statement (no replies)

$
0
0
I have been hunting down a memory corruption issue with the results of C++/Connector for the last couple of days.

The issue really only shows up when using a prepared statement, and the resul is of type MYSQL_TYPE_VAR_STRING > 64 bytes in length. In my case the result was 70 characters in length and would get corrupted after the 64th byte.

I have narrowed down the bug to here -
mysql_resultbind.cpp in allocate_buffer_for_field():

case MYSQL_TYPE_VAR_STRING:
#if LIBMYSQL_VERSION_ID > 50700
case MYSQL_TYPE_JSON:
return st_buffer_size_type(new char[field->max_length + 1], field->max_length + 1, field->type);
#endif //LIBMYSQL_VERSION_ID > 50700

For some reason LIBMYSQL_VERSION_ID is not set at all at this point (but MYSQL_VERSION_ID) is. I haven't figured out why its not set yet...

So the switch falls thru to MYSQL_TYPE_DECIMAL and allocates a fixed 64 bytes.
This behavior does not seem correct, why would a VAR_STRING ever fall through to a fixed 64 bytes?

I feel like the return statement should be outside of the #if/#endif and it is a bug having it inside the #if statement.

Can one of the developers elaborate?

Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>