This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Uninitialised Variable in symfile.c


There is a codepath is "load_section_callback" where the variable "err" will not end up being assigned a value, and hence will default to whatever happened to be on the stack at its location. And in my case, it was defaulting to a vlaue which signaled an error, when none had occured.

This causes the following problem:

When attempting a "load" to a remote target, "load" fails after first packet is successfuly transfered to the target with:

Loading section .text, size 0xdc220 lma 0x0
Sending packet: $X0,400:.....
[$][O][K][#][9][a]Packet received: OK
remote:target_xfer_partial (2, (null), 0x0, 0x40ed9008, 0x0, 1024) = 1024, bytes = 48 00 40 00 41 50 50 20 ...
Memory access error while loading section .text.


The call to "target_write_memory_partial" will not set "err" if it uses "target_xfer_partial" to do the memory transfer, as "target_xfer_partial" does not take "err" as a parameter.

The attached patch fixes this, by simply defaulting "err" to 0, the OK state.

This is the subject of PR# 1944

Steven Johnson
diff -Naur gdb-6.3/gdb/symfile.c gdb-6.3-modified/gdb/symfile.c
--- gdb-6.3/gdb/symfile.c	2004-09-30 23:23:09.000000000 -1100
+++ gdb-6.3-modified/gdb/symfile.c	2005-05-14 21:01:18.959321653 -1100
@@ -1405,7 +1405,7 @@
 	  struct cleanup *old_chain;
 	  CORE_ADDR lma = bfd_section_lma (abfd, asec) + args->load_offset;
 	  bfd_size_type block_size;
-	  int err;
+	  int err = 0;
 	  const char *sect_name = bfd_get_section_name (abfd, asec);
 	  bfd_size_type sent;
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]