summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/dexbnf/type.c11
-rw-r--r--plugins/itanium/abi.c20
-rw-r--r--plugins/itanium/component.c5
-rw-r--r--plugins/javadesc/field.c15
-rw-r--r--plugins/pychrysalide/analysis/type.c22
5 files changed, 61 insertions, 12 deletions
diff --git a/plugins/dexbnf/type.c b/plugins/dexbnf/type.c
index db838c1..b1e4155 100644
--- a/plugins/dexbnf/type.c
+++ b/plugins/dexbnf/type.c
@@ -66,6 +66,7 @@ static GDataType *dtd_full_class_name(input_buffer *buffer)
size_t saved; /* Point de sauvegarde */
char next; /* Prochain caractère obtenu */
GDataType *ns; /* Espace de nom à attribuer */
+ bool status; /* Bilan de rattachement */
/**
* Les règles traitées sont les suivantes :
@@ -116,7 +117,15 @@ static GDataType *dtd_full_class_name(input_buffer *buffer)
result = g_class_enum_type_new(CEK_CLASS, name);
- g_data_type_set_namespace(result, ns, strdup("."));
+ status = g_data_type_set_namespace(result, ns, ".");
+
+ g_object_unref(G_OBJECT(ns));
+
+ if (!status)
+ {
+ g_clear_object(&result);
+ break;
+ }
}
while (1);
diff --git a/plugins/itanium/abi.c b/plugins/itanium/abi.c
index 213d5f7..393a8d6 100644
--- a/plugins/itanium/abi.c
+++ b/plugins/itanium/abi.c
@@ -2194,6 +2194,7 @@ static itanium_component *itd_builtin_type(GItaniumDemangling *context)
GDataType *std; /* Espace de noms */
itanium_component *vendor; /* Extension propriétaire */
GDataType *builtin; /* Type construit */
+ bool status; /* Bilan de rattachement */
/**
* La règle traitée ici est la suivante :
@@ -2351,7 +2352,16 @@ static itanium_component *itd_builtin_type(GItaniumDemangling *context)
std = g_class_enum_type_new(CEK_NAMESPACE, strdup("std"));
builtin = g_class_enum_type_new(CEK_CLASS, strdup("nullptr_t"));
- g_data_type_set_namespace(builtin, std, strdup("::"));
+ status = g_data_type_set_namespace(builtin, std, "::");
+
+ g_object_unref(G_OBJECT(std));
+
+ if (!status)
+ {
+ g_object_unref(G_OBJECT(builtin));
+ result = NULL;
+ goto done;
+ }
result = itd_make_type(builtin);
itd_set_type(result, ICT_STD_SUBST);
@@ -3438,6 +3448,7 @@ static itanium_component *itd_substitution(GItaniumDemangling *context)
const itanium_std_subst_info *stdinfo; /* Raccourci de confort */
GDataType *std; /* Espace de noms */
GDataType *type; /* Type complet final */
+ bool status; /* Bilan de rattachement */
/**
* La règle traitée ici est la suivante :
@@ -3488,7 +3499,12 @@ static itanium_component *itd_substitution(GItaniumDemangling *context)
else
{
type = g_class_enum_type_new(CEK_CLASS, strdup(stdinfo->class));
- g_data_type_set_namespace(type, std, strdup("::"));
+ status = g_data_type_set_namespace(type, std, "::");
+ g_object_unref(G_OBJECT(std));
+
+ if (!status)
+ break;
+
}
result = itd_make_type(type);
diff --git a/plugins/itanium/component.c b/plugins/itanium/component.c
index 558936a..b2f004b 100644
--- a/plugins/itanium/component.c
+++ b/plugins/itanium/component.c
@@ -1370,7 +1370,10 @@ static void itd_prepend_namespace_to_type(GDataType *type, GDataType *ns)
existing = g_data_type_get_namespace(type);
if (existing == NULL)
- g_data_type_set_namespace(type, ns, strdup("::"));
+ {
+ g_data_type_set_namespace(type, ns, "::");
+ g_object_unref(G_OBJECT(ns));
+ }
else
{
diff --git a/plugins/javadesc/field.c b/plugins/javadesc/field.c
index 799d39d..6396e03 100644
--- a/plugins/javadesc/field.c
+++ b/plugins/javadesc/field.c
@@ -66,6 +66,7 @@ static GDataType *jtd_object_type_descriptor(input_buffer *buffer)
GDataType *root; /* Espace de noms racine */
GDataType *ns; /* Espace de noms à attribuer */
GDataType *parent; /* Espace de noms parent */
+ bool status; /* Bilan de rattachement */
result = NULL;
@@ -108,7 +109,7 @@ static GDataType *jtd_object_type_descriptor(input_buffer *buffer)
ns = g_data_type_get_namespace(result);
if (ns == NULL)
- g_data_type_set_namespace(result, root, strdup("."));
+ status = g_data_type_set_namespace(result, root, ".");
else
{
@@ -118,12 +119,20 @@ static GDataType *jtd_object_type_descriptor(input_buffer *buffer)
ns = parent;
}
- g_data_type_set_namespace(ns, root, strdup("."));
+ status = g_data_type_set_namespace(ns, root, ".");
g_object_unref(G_OBJECT(ns));
}
+ g_object_unref(G_OBJECT(root));
+
+ if (!status)
+ {
+ g_clear_object(&result);
+ goto error;
+ }
+
}
break;
@@ -156,6 +165,8 @@ static GDataType *jtd_object_type_descriptor(input_buffer *buffer)
if (name != NULL)
result = g_class_enum_type_new(CEK_CLASS, name);
+ error:
+
return result;
}
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;