Menu

#116 CppDb: random data when passing temporal strings as values

cppcms-v1.0.x
open
nobody
None
1
2014-10-30
2014-03-27
Anonymous
No

This (simplified) example shows case when cppdb stores random data in MySQL:

cppdb::session ses;
ses << "INSERT INTO stats(ip, referer) VALUES(?, ?)"
<< app.request().remote_addr()
<< app.request().http_referer()
<< cppdb::exec;

The reason is that cppdb only stores references to passed string. It does not create internal copies. In this examples values returned by remote_addr() and http_referer() are temporal string that disappear before the statement is executed; Internal cppdb reference references in this case some random memory in allocator and random data is stored in a database.

This behavior is highly unexpected and has generated multiple issues for me.

Discussion

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.