-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 a crash if value isn't UTF8 string #523
base: master
Are you sure you want to change the base?
Conversation
Hello @elliotfiske - can you make a unit test that shows the crash in action? |
updated! Let me know if you have any questions/I need to adjust something. |
In your first patch, you have it setting the value to null, and then in another one you have it set to [NSString stringWithCString:values[i] encoding:NSASCIIStringEncoding]. Falling back on NSASCIIStringEncoding is a bad idea in my opinion, because we don't do that anywhere else, and UTF-8 is the way to go anyway. Any reason why you changed it from NSNull? |
I changed it from NSNull because there is actually data there, it's just not encodable to a UTF-8 string. I'm actually thinking it might make more sense to return NSData now, do you think that would make more sense? |
I think putting anything other than NSString at this point would be a bad idea, because that could break applications today. However, for 3.0 it would make sense to look at the sqlite type being returned, and then massage the data to that. So for now, it should probably be NSNull (which is what FMDB does elsewhere, so it's consistent at least) |
I think for now we should keep the noisy crash instead of silently returning Null for BLOB data, and push off the problem off to 3.0, especially since I realize now we might return bad data – if the binary data has a 0-byte, it'll truncate it because it's a C-style string. |
No description provided.