Skip to content

Commit bc56ace

Browse files
committed
Proper TypeError exception handling.
1 parent e4f66cc commit bc56ace

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

journald.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ journald_send(PyObject *self, PyObject *args) {
1717
for (i = 0; i < argc; ++i) {
1818
PyObject *item = PyTuple_GetItem(args, i);
1919
char * stritem = PyString_AsString(item);
20+
if (stritem == NULL) {
21+
// PyString_AsString has already raised TypeError at this
22+
// point. We can just free iov and return NULL.
23+
free(iov);
24+
return NULL;
25+
}
2026
iov[i].iov_base = stritem;
2127
iov[i].iov_len = strlen(stritem);
2228
}

0 commit comments

Comments
 (0)