Skip to content

Commit dcb7b18

Browse files
committed
Bulletproof Location.file against NULL filename
1 parent 1e69eba commit dcb7b18

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

generate-location-c.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Copyright 2011, 2012, 2013 David Malcolm <dmalcolm@redhat.com>
2-
# Copyright 2011, 2012, 2013 Red Hat, Inc.
1+
# Copyright 2011, 2012, 2013, 2014 David Malcolm <dmalcolm@redhat.com>
2+
# Copyright 2011, 2012, 2013, 2014 Red Hat, Inc.
33
#
44
# This is free software: you can redistribute it and/or modify it
55
# under the terms of the GNU General Public License as published by
@@ -38,7 +38,11 @@ def generate_location():
3838
static PyObject *
3939
PyGccLocation_get_file(struct PyGccLocation *self, void *closure)
4040
{
41-
return PyGccString_FromString(gcc_location_get_filename(self->loc));
41+
const char *filename = gcc_location_get_filename(self->loc);
42+
if (!filename) {
43+
Py_RETURN_NONE;
44+
}
45+
return PyGccString_FromString(filename);
4246
}
4347
""")
4448

0 commit comments

Comments
 (0)