]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
fix division by zero in target_read_string()
authorKilian Kilger <kkilger@gmail.com>
Sun, 26 May 2024 08:41:12 +0000 (10:41 +0200)
committerTom Tromey <tromey@adacore.com>
Tue, 11 Jun 2024 15:50:08 +0000 (09:50 -0600)
Under certain circumstances, a floating point exception in
target_read_string() can happen when the type has been obtained
by a call to stpy_lazy_string_elt_type(). In the latter function,
a call to check_typedef() has been forgotten. This makes
type->length = 0 in this case.

gdb/python/py-lazy-string.c

index 0b7f5c9d680aea1661fbd9ee28921d0ad6995438..8779716c4b914e17ae461d0b5f18dce80733cb0e 100644 (file)
@@ -266,7 +266,7 @@ stpy_lazy_string_elt_type (lazy_string_object *lazy)
     {
     case TYPE_CODE_PTR:
     case TYPE_CODE_ARRAY:
-      return realtype->target_type ();
+      return check_typedef (realtype->target_type ());
     default:
       /* This is done to preserve existing behaviour.  PR 20769.
         E.g., gdb.parse_and_eval("my_int_variable").lazy_string().type.  */