Commit 45cfe389 authored by Lukáš Lalinský's avatar Lukáš Lalinský

Safer fingerprint decoding

parent 042b7af4
Pipeline #20576 failed with stages
in 3 minutes and 57 seconds
......@@ -142,12 +142,16 @@ class Fingerprinter(object):
def decode_fingerprint(data, base64=True):
result_ptr = ctypes.POINTER(ctypes.c_int32)()
result_size = ctypes.c_int()
algorithm = ctypes.c_int()
result_size = ctypes.c_int(0)
algorithm = ctypes.c_int(-1)
_check(_libchromaprint.chromaprint_decode_fingerprint(
data, len(data), ctypes.byref(result_ptr), ctypes.byref(result_size),
ctypes.byref(algorithm), 1 if base64 else 0
))
if algorithm.value == -1:
raise FingerprintError()
if result_size.value == 0:
raise FingerprintError()
result = result_ptr[:result_size.value]
_libchromaprint.chromaprint_dealloc(result_ptr)
return result, algorithm.value
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment