]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Check gdb_python_module in gdbpy_handle_missing_debuginfo
authorTom Tromey <tromey@adacore.com>
Wed, 15 Nov 2023 13:48:55 +0000 (06:48 -0700)
committerTom Tromey <tromey@adacore.com>
Wed, 15 Nov 2023 16:43:38 +0000 (09:43 -0700)
If you run gdb in the build tree without --data-directory, on a
program that does not have debug info, it will crash, because
gdbpy_handle_missing_debuginfo unconditionally uses gdb_python_module.

Other code in gdb using gdb_python_module checks it first and it
seemes harmless to do the same thing here.  (gdb_python_initialized
does not cover this case so that python can be partially initialized
and still somewhat work.)

gdb/python/python.c

index 4523e30ed249efe3936e16d08e8681d377f4ed89..7e48165db21abd3f4717e786f454ea90db788b1d 100644 (file)
@@ -1703,7 +1703,7 @@ gdbpy_handle_missing_debuginfo (const struct extension_language_defn *extlang,
                                struct objfile *objfile)
 {
   /* Early exit if Python is not initialised.  */
-  if (!gdb_python_initialized)
+  if (!gdb_python_initialized || gdb_python_module == nullptr)
     return {};
 
   struct gdbarch *gdbarch = objfile->arch ();