Fix off-by-one error in compute_delayed_physnames

Message ID 20231123053132.608835-1-tom@tromey.com
State New
Headers
Series Fix off-by-one error in compute_delayed_physnames |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Tom Tromey Nov. 23, 2023, 5:31 a.m. UTC
  compute_delayed_physnames does this:

	  size_t len = strlen (physname);
...
	      if (physname[len] == ')') /* shortcut */
		break;

However, physname[len] will always be \0.

This patch changes it to the correct len-1.
---
 gdb/dwarf2/read.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Tom Tromey Dec. 4, 2023, 6:46 p.m. UTC | #1
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> compute_delayed_physnames does this:
Tom> 	  size_t len = strlen (physname);
Tom> ...
Tom> 	      if (physname[len] == ')') /* shortcut */
Tom> 		break;

Tom> However, physname[len] will always be \0.

Tom> This patch changes it to the correct len-1.

This is fairly trivial; I'm going to check it in now.

Tom
  

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 9f3297a2d4e..c4943362fa2 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -5647,7 +5647,7 @@  compute_delayed_physnames (struct dwarf2_cu *cu)
 
 	  while (1)
 	    {
-	      if (physname[len] == ')') /* shortcut */
+	      if (physname[len - 1] == ')') /* shortcut */
 		break;
 	      else if (check_modifier (physname, len, " const"))
 		TYPE_FN_FIELD_CONST (fn_flp->fn_fields, mi.index) = 1;