pypyodbc icon indicating copy to clipboard operation
pypyodbc copied to clipboard

C-string termination

Open zhkvia opened this issue 7 years ago • 1 comments

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

zhkvia avatar Nov 13 '17 10:11 zhkvia

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

braian87b avatar Jun 17 '18 22:06 braian87b