summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/analysis
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/analysis')
-rw-r--r--plugins/pychrysalide/analysis/type.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/plugins/pychrysalide/analysis/type.c b/plugins/pychrysalide/analysis/type.c
index 1e4ec06..303d188 100644
--- a/plugins/pychrysalide/analysis/type.c
+++ b/plugins/pychrysalide/analysis/type.c
@@ -718,7 +718,7 @@ static PyObject *py_data_type_get_namespace(PyObject *self, void *closure)
PyObject *result; /* Valeur à retourner */
GDataType *type; /* Elément à consulter */
GDataType *ns; /* Espace de noms */
- const char *sep; /* Séparateur d'espace */
+ char *sep; /* Séparateur d'espace */
#define DATA_TYPE_NAMESPACE_ATTRIB PYTHON_GETSET_DEF_FULL \
( \
@@ -744,13 +744,17 @@ static PyObject *py_data_type_get_namespace(PyObject *self, void *closure)
g_object_unref(G_OBJECT(ns));
PyTuple_SetItem(result, 1, PyUnicode_FromString(sep));
+ free(sep);
}
else
{
+ assert(ns == NULL && sep == NULL);
+
result = Py_None;
Py_INCREF(result);
+
}
return result;
@@ -775,8 +779,9 @@ static PyObject *py_data_type_get_namespace(PyObject *self, void *closure)
static int py_data_type_set_namespace(PyObject *self, PyObject *value, void *closure)
{
GDataType *type; /* Elément à traiter */
+ bool status; /* Echec de l'inscription */
GDataType *ns; /* Espace de noms */
- char *sep; /* Séparateur des espaces */
+ const char *sep; /* Séparateur des espaces */
if ((!PyTuple_Check(value) || (PyTuple_Check(value) && PyTuple_Size(value) != 2)) && value != Py_None)
{
@@ -788,7 +793,7 @@ static int py_data_type_set_namespace(PyObject *self, PyObject *value, void *clo
type = G_DATA_TYPE(pygobject_get(self));
if (value == Py_None)
- g_data_type_set_namespace(type, NULL, NULL);
+ status = g_data_type_set_namespace(type, NULL, NULL);
else
{
@@ -805,11 +810,16 @@ static int py_data_type_set_namespace(PyObject *self, PyObject *value, void *clo
}
ns = G_DATA_TYPE(pygobject_get(PyTuple_GetItem(value, 0)));
- sep = strdup(PyUnicode_DATA(PyTuple_GetItem(value, 1)));
+ sep = PyUnicode_DATA(PyTuple_GetItem(value, 1));
+
+ status = g_data_type_set_namespace(type, ns, sep);
- g_object_ref(G_OBJECT(ns));
- g_data_type_set_namespace(type, ns, sep);
+ }
+ if (!status)
+ {
+ PyErr_SetString(PyExc_TypeError, _("Failed while registering the type namespace (!)"));
+ return -1;
}
return 0;