Skip to content

Commit

Permalink
Merge pull request #65 from luc1ph3r/Fix_skew_write_to_buffer
Browse files Browse the repository at this point in the history
Guarantee a C-string termination
  • Loading branch information
braian87b authored Jun 17, 2018
2 parents e204b88 + 677aadb commit 5859511
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pypyodbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,8 @@ def fetchone(self):
if target_type == SQL_C_BINARY:
value_list.append(buf_cvt_func(alloc_buffer.raw[:used_buf_len.value]))
elif target_type == SQL_C_WCHAR:
if used_buf_len.value < total_buf_len:
ctypes.memset(ctypes.addressof(alloc_buffer) + used_buf_len.value, 0, 1)
value_list.append(buf_cvt_func(from_buffer_u(alloc_buffer)))
elif alloc_buffer.value == '':
value_list.append(None)
Expand Down

0 comments on commit 5859511

Please sign in to comment.