Skip to content
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

Correctly handle cases where detected data contains null-bytes #76

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pyzbar/pyzbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
zbar_image_scanner_create, zbar_image_scanner_destroy,
zbar_image_create, zbar_image_destroy, zbar_image_set_format,
zbar_image_set_size, zbar_image_set_data, zbar_scan_image,
zbar_image_first_symbol, zbar_symbol_get_data,
zbar_image_first_symbol, zbar_symbol_get_data_length, zbar_symbol_get_data,
zbar_symbol_get_loc_size, zbar_symbol_get_loc_x, zbar_symbol_get_loc_y,
zbar_symbol_next, ZBarConfig, ZBarSymbol, EXTERNAL_DEPENDENCIES
)
Expand Down Expand Up @@ -97,7 +97,10 @@ def _decode_symbols(symbols):
Decoded: decoded symbol
"""
for symbol in symbols:
data = string_at(zbar_symbol_get_data(symbol))
data = string_at(
zbar_symbol_get_data(symbol),
zbar_symbol_get_data_length(symbol)
)
# The 'type' int in a value in the ZBarSymbol enumeration
symbol_type = ZBarSymbol(symbol.contents.type).name
polygon = convex_hull(
Expand Down
7 changes: 4 additions & 3 deletions pyzbar/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
'zbar_image_scanner_create', 'zbar_image_scanner_destroy',
'zbar_image_scanner_set_config', 'zbar_image_set_data',
'zbar_image_set_format', 'zbar_image_set_size', 'zbar_scan_image',
'zbar_symbol_get_data', 'zbar_symbol_get_loc_size',
'zbar_symbol_get_loc_x', 'zbar_symbol_get_loc_y', 'zbar_symbol_next'
'zbar_symbol_get_data_length', 'zbar_symbol_get_data',
'zbar_symbol_get_loc_size', 'zbar_symbol_get_loc_x',
'zbar_symbol_get_loc_y', 'zbar_symbol_next'
]

# Globals populated in load_libzbar
Expand Down Expand Up @@ -234,7 +235,7 @@ def zbar_function(fname, restype, *args):

zbar_symbol_get_data = zbar_function(
'zbar_symbol_get_data',
c_char_p,
c_ubyte_p,
POINTER(zbar_symbol)
)

Expand Down