Skip to content

Commit 28d45ac

Browse files
authored
Merge pull request #1238 from matejak/cov-swig-fix
Improved error handling using SWIG_fail.
2 parents 2f5331f + 971b8b9 commit 28d45ac

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

swig/src/openscap.i

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
$1 = (time_t) PyFloat_AsDouble($input);
5252
else {
5353
PyErr_SetString(PyExc_TypeError,"Expected a large number");
54-
return NULL;
54+
SWIG_fail;
5555
}
5656
}
5757

@@ -89,7 +89,7 @@
8989
} else {
9090
free($1);
9191
PyErr_SetString(PyExc_TypeError,"not a list");
92-
return NULL;
92+
SWIG_fail;
9393
}
9494
}
9595

@@ -106,11 +106,11 @@
106106

107107
if (!PySequence_Check($input)) {
108108
PyErr_SetString(PyExc_ValueError,"Expected a sequence");
109-
return NULL;
109+
SWIG_fail;
110110
}
111111
if (a_size <= 0) {
112112
PyErr_SetString(PyExc_ValueError,"Expected not empty sequence");
113-
return NULL;
113+
SWIG_fail;
114114
}
115115

116116
$1 = (struct cpe_name **) malloc(a_size*sizeof(struct cpe_name *));
@@ -119,12 +119,12 @@
119119
PyObject *obj = PySequence_GetItem($input,i);
120120
if (obj == NULL) {
121121
SWIG_exception_fail(SWIG_ArgError(res_o), "in argument '" "cpe_name" "' substitution '" "', can't access sequence");
122-
return NULL; /*5956*/
122+
SWIG_fail; /*5956*/
123123
}
124124
res_o = SWIG_ConvertPtr(obj, &arg, SWIGTYPE_p_cpe_name, 0 );
125125
if (!SWIG_IsOK(res_o)) {
126126
SWIG_exception_fail(SWIG_ArgError(res_o), "in argument '" "cpe_name" "' substitution invalid types");
127-
return NULL;
127+
SWIG_fail;
128128
}
129129
$1[i] = (struct cpe_name *) arg;
130130
}
@@ -138,11 +138,11 @@
138138

139139
if (!PySequence_Check($input)) {
140140
PyErr_SetString(PyExc_ValueError,"Expected a sequence");
141-
return NULL;
141+
SWIG_fail;
142142
}
143143
if (a_size <= 0) {
144144
PyErr_SetString(PyExc_ValueError,"Expected not empty sequence");
145-
return NULL;
145+
SWIG_fail;
146146
}
147147

148148
$1 = (struct oval_syschar_model **) malloc(a_size*sizeof(struct oval_syschar_model *));
@@ -151,12 +151,12 @@
151151
PyObject *obj = PySequence_GetItem($input,i);
152152
if (obj == NULL) {
153153
SWIG_exception_fail(SWIG_ArgError(res_o), "in argument '" "oval_syschar_model" "' substitution '" "', can't access sequence");
154-
return NULL;
154+
SWIG_fail;
155155
}
156156
res_o = SWIG_ConvertPtr(obj, &arg, SWIGTYPE_p_oval_syschar_model, 0 );
157157
if (!SWIG_IsOK(res_o)) {
158158
SWIG_exception_fail(SWIG_ArgError(res_o), "in argument '" "oval_syschar_model" "' substitution invalid types");
159-
return NULL;
159+
SWIG_fail;
160160
}
161161
$1[i] = (struct oval_syschar_model *) arg;
162162
}

0 commit comments

Comments
 (0)