diff options
author | Justus Winter <[email protected]> | 2016-06-07 14:07:33 +0000 |
---|---|---|
committer | Justus Winter <[email protected]> | 2016-06-07 17:34:51 +0000 |
commit | f8f9bf06bc3190968ba6613032d60a3bf2c8a6d9 (patch) | |
tree | 46efd8832cf1eee72940d52972347c2e0299a7e2 | |
parent | python: Wrap file-like objects on demand. (diff) | |
download | gpgme-f8f9bf06bc3190968ba6613032d60a3bf2c8a6d9.tar.gz gpgme-f8f9bf06bc3190968ba6613032d60a3bf2c8a6d9.zip |
python: Fix error handling.
* lang/python/gpgme.i: Fix freeing an uninitialized pointer in the
error handling of generated wrapper functions by explicitly storing
the pointer in a local variable which can be initialized.
Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to '')
-rw-r--r-- | lang/python/gpgme.i | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i index e3695823..f466a874 100644 --- a/lang/python/gpgme.i +++ b/lang/python/gpgme.i @@ -1,4 +1,5 @@ /* +# Copyright (C) 2016 g10 Code GmbH # Copyright (C) 2004,2008 Igor Belyi <[email protected]> # Copyright (C) 2002 John Goerzen <[email protected]> # @@ -42,11 +43,11 @@ %typemap(freearg) const char * ""; /* Likewise for a list of strings. */ -%typemap(in) const char *[] { +%typemap(in) const char *[] (void *vector = NULL) { /* Check if is a list */ if (PyList_Check($input)) { size_t i, size = PyList_Size($input); - $1 = (char **) malloc((size+1) * sizeof(char *)); + $1 = (char **) (vector = malloc((size+1) * sizeof(char *))); for (i = 0; i < size; i++) { PyObject *o = PyList_GetItem($input,i); @@ -72,7 +73,7 @@ } } %typemap(freearg) const char *[] { - free((char *) $1); + free(vector$argnum); } // Release returned buffers as necessary. |