forked from Imagelibrary/binutils-gdb
gdb/python: Fix segfault when iterating over empty linetable
symtab-> linetable () is set to null in buildsym_compunit::end_compunit_symtab_with_blockvector () if the symtab has no linetable. Attempting to iterate over this linetable using the Python API caused GDB to segfault. Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
@@ -397,7 +397,8 @@ ltpy_iternext (PyObject *self)
|
||||
|
||||
LTPY_REQUIRE_VALID (iter_obj->source, symtab);
|
||||
|
||||
if (iter_obj->current_index >= symtab->linetable ()->nitems)
|
||||
if (symtab->linetable () == nullptr
|
||||
|| iter_obj->current_index >= symtab->linetable ()->nitems)
|
||||
{
|
||||
PyErr_SetNone (PyExc_StopIteration);
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user