python: Correctly translate to size_t.
* lang/python/gpgme.i: Correctly translate Python number to size_t. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
1d80e7374a
commit
c38fabfea0
@ -329,14 +329,29 @@
|
|||||||
PyErr_SetString(PyExc_TypeError, "Numeric argument expected");
|
PyErr_SetString(PyExc_TypeError, "Numeric argument expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Those are for gpgme_data_read() and gpgme_strerror_r()
|
/* Those are for gpgme_data_read() and gpgme_strerror_r(). */
|
||||||
%typemap(in) (void *buffer, size_t size), (char *buf, size_t buflen) {
|
%typemap(in) (void *buffer, size_t size), (char *buf, size_t buflen) {
|
||||||
$2 = PyLong_AsLong($input);
|
{
|
||||||
if ($2 < 0) {
|
long tmp$argnum;
|
||||||
PyErr_SetString(PyExc_ValueError, "Positive integer expected");
|
if (PyLong_Check($input))
|
||||||
return NULL;
|
tmp$argnum = PyLong_AsLong($input);
|
||||||
}
|
#if PY_MAJOR_VERSION < 3
|
||||||
$1 = ($1_ltype) malloc($2+1);
|
else if (PyInt_Check($input))
|
||||||
|
tmp$argnum = PyInt_AsLong($input);
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PyErr_SetString(PyExc_TypeError, "Numeric argument expected");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tmp$argnum < 0) {
|
||||||
|
PyErr_SetString(PyExc_ValueError, "Positive integer expected");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
$2 = (size_t) tmp$argnum;
|
||||||
|
$1 = ($1_ltype) malloc($2+1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
%typemap(argout) (void *buffer, size_t size), (char *buf, size_t buflen) {
|
%typemap(argout) (void *buffer, size_t size), (char *buf, size_t buflen) {
|
||||||
Py_XDECREF($result); /* Blow away any previous result */
|
Py_XDECREF($result); /* Blow away any previous result */
|
||||||
|
Loading…
Reference in New Issue
Block a user