This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Prevent crashes with bad -g options
- From: Stan Shebs <shebs at apple dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 31 Aug 2004 16:16:13 -0700
- Subject: PATCH: Prevent crashes with bad -g options
If one passes an inappropriate debugging option, such as -gvms to
darwin, the compiler will dutifully produce an error message, but
then go on to dereference an uninitialized debug_hooks and crash.
This patch just ensures that it's initialized no matter what the
tangle of conditionals; almost obvious, but perhaps there's a
better way to solve.
OK for mainline?
Stan
* toplev.c (process_options): Ensure debug_hooks is initialized.
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.913
diff -p -r1.913 toplev.c
*** toplev.c 26 Aug 2004 16:42:39 -0000 1.913
--- toplev.c 31 Aug 2004 23:06:08 -0000
*************** process_options (void)
*** 1806,1813 ****
default_debug_hooks = &vmsdbg_debug_hooks;
#endif
if (write_symbols == NO_DEBUG)
! debug_hooks = &do_nothing_debug_hooks;
#if defined(DBX_DEBUGGING_INFO)
else if (write_symbols == DBX_DEBUG)
debug_hooks = &dbx_debug_hooks;
--- 1806,1814 ----
default_debug_hooks = &vmsdbg_debug_hooks;
#endif
+ debug_hooks = &do_nothing_debug_hooks;
if (write_symbols == NO_DEBUG)
! ;
#if defined(DBX_DEBUGGING_INFO)
else if (write_symbols == DBX_DEBUG)
debug_hooks = &dbx_debug_hooks;