pypyodbc
pypyodbc copied to clipboard
C-string termination
I've noticed that sometimes, after SQLGetData
call, alloc_buffer
becomes dirty in a sense that it's not properly terminated by the \x00
character. Because of that, when you want to decode a string (let's say, it's encoded in utf-8
), after truncating it by the \x00
character, you get not only a desired string but also a part of a previous string that was written to the same buffer and a decoding process may fail.
Here's a quick fix for that: PR
UPD:
OSes I use: Linux
/ macOS
ODBC Driver: unixODBC
Excelent, 'sometimes' in which cases? have you find on which cases or it is a random like issue? Are you still using unixODBC or have you tried the official Microsoft ODCB Driver for Linux / Mac https://github.com/jiangwen365/pypyodbc/wiki/How-to-use-pypyodbc-on-MacOS-OSX