-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ByteArrayParameter::writeTo(SQLString& str) for negative sql::bytes::length #24
base: master
Are you sure you want to change the base?
Conversation
…es::length sql::bytes::length may be negative. That ByteArrayParameter::writeTo(SQLString& str) static_cast it directly to size_t causes unexpected result in this case.
Thank you for your pull request. Looks valid. But first - formalities. |
void SetBytesAndExecute(sql::PreparedStatement* PreparedStatement, int32_t ParameterIndex)
{
char NonConstChars[2];
sql::bytes Bytes = sql::bytes(NonConstChars, 2);//The non-const char array selects a special overload that sets the length to be negative
PreparedStatement->setBytes(ParameterIndex, &Bytes);
PreparedStatement->execute();//string too long
} I don't mind writing a test, but I find the directory structure under |
|
I've noticed that |
For now it's better to change all length uses in ByteArrayClass to size(). It maybe worse considering to make it always make the copy of array or always refer the given array, ans so always have either positive or negative length. But that is another story. For now size() is the way to go 1 test should suffice - proving that array w/ negative length does not crash the program and works correctly. |
sql::bytes::length
may be negative. ThatByteArrayParameter::writeTo(SQLString& str) static_cast
it directly tosize_t
causes unexpected result in this case.