Skip to content

Commit 0527f1c

Browse files
committed
check input when using strdup(v)
1 parent 51ad4c9 commit 0527f1c

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/gstype_python.i

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,14 +1225,20 @@ static bool convertToFieldWithType(GSRow *row, int column, PyObject* value, GSTy
12251225
%variable_fail(res, "String", "name");
12261226
}
12271227

1228-
$1[i].name = strdup(v);
1229-
cleanString(v, alloc[j]);
1228+
if (v) {
1229+
$1[i].name = strdup(v);
1230+
cleanString(v, alloc[j]);
1231+
} else {
1232+
$1[i].name = NULL;
1233+
}
12301234
res = SWIG_AsCharPtrAndSize(val, &v, &size, &alloc[j + 1]);
12311235
if (!SWIG_IsOK(res)) {
12321236
%variable_fail(res, "String", "value");
12331237
}
1234-
$1[i].value = strdup(v);
1235-
cleanString(v, alloc[j + 1]);
1238+
if (v) {
1239+
$1[i].value = strdup(v);
1240+
cleanString(v, alloc[j + 1]);
1241+
}
12361242
i++;
12371243
j+=2;
12381244
}

0 commit comments

Comments
 (0)