quvi: fix crashes on calls to quvi functions
When a function returns a char*, it is necessary to tell it to ctypes, instead it returns an integer. On a 64 bits CPU, pointers can overflow the integer, and result to an unvalid pointer given to c_char_p.
This commit is contained in:
parent
7819b011ba
commit
d961459349
2 changed files with 8 additions and 3 deletions
|
|
@ -103,6 +103,9 @@ class QuviVideo(BaseVideo):
|
||||||
if _id.startswith('http'):
|
if _id.startswith('http'):
|
||||||
return _id
|
return _id
|
||||||
|
|
||||||
|
if not '.' in _id:
|
||||||
|
raise UserError('Please give an ID in form WEBSITE.ID (for example youtube.BaW_jenozKc). Supported websites are: %s' % ', '.join(cls.BACKENDS.keys()))
|
||||||
|
|
||||||
sub_backend, sub_id = _id.split('.', 1)
|
sub_backend, sub_id = _id.split('.', 1)
|
||||||
try:
|
try:
|
||||||
return cls.BACKENDS[sub_backend] % sub_id
|
return cls.BACKENDS[sub_backend] % sub_id
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,8 @@ class LibQuvi04(object):
|
||||||
if self.lib is None:
|
if self.lib is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
version_str = c_char_p(self.lib.quvi_version(self.QUVI_VERSION)).value
|
self.lib.quvi_version.restype = c_char_p
|
||||||
|
version_str = self.lib.quvi_version(self.QUVI_VERSION)
|
||||||
if version_str.startswith('v0.4'):
|
if version_str.startswith('v0.4'):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
|
@ -108,8 +109,9 @@ class LibQuvi04(object):
|
||||||
|
|
||||||
def _assert_ok(self, status):
|
def _assert_ok(self, status):
|
||||||
if status != self.QUVI_OK:
|
if status != self.QUVI_OK:
|
||||||
c_msg = c_char_p(self.lib.quvi_strerror(self.qh, status))
|
self.lib.quvi_strerror.restype = c_char_p
|
||||||
raise QuviError(c_msg.value)
|
c_msg = self.lib.quvi_strerror(self.qh, status)
|
||||||
|
raise QuviError(c_msg)
|
||||||
|
|
||||||
def _get_str(self, prop):
|
def _get_str(self, prop):
|
||||||
c_value = c_char_p()
|
c_value = c_char_p()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue