public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Add missing guard in __gnat_adjust_context_for_raise
@ 2009-11-30 13:53 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2009-11-30 13:53 UTC (permalink / raw)
  To: gcc-patches; +Cc: Eric Botcazou

[-- Attachment #1: Type: text/plain, Size: 346 bytes --]

This makes sure the pattern matching code in __gnat_adjust_context_for_raise
doesn't dereference a NULL pointer in case things go awry.

Tested on x86_64-pc-linux-gnu, committed on trunk

2009-11-30  Eric Botcazou  <ebotcazou@adacore.com>

	* init.c (__gnat_adjust_context_for_raise, Linux version): Add guard
	for null PC saved in the context.


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1164 bytes --]

Index: init.c
===================================================================
--- init.c	(revision 154755)
+++ init.c	(working copy)
@@ -601,14 +601,14 @@ __gnat_adjust_context_for_raise (int sig
      time this happens.  */
 
 #if defined (i386)
-  unsigned long pattern = *(unsigned long *)mcontext->gregs[REG_EIP];
+  unsigned long *pc = (unsigned long *)mcontext->gregs[REG_EIP];
   /* The pattern is "orl $0x0,(%esp)" for a probe in 32-bit mode.  */
-  if (signo == SIGSEGV && pattern == 0x00240c83)
+  if (signo == SIGSEGV && pc && *pc == 0x00240c83)
     mcontext->gregs[REG_ESP] += 4096 + 4 * sizeof (unsigned long);
 #elif defined (__x86_64__)
-  unsigned long pattern = *(unsigned long *)mcontext->gregs[REG_RIP];
+  unsigned long *pc = (unsigned long *)mcontext->gregs[REG_RIP];
   /* The pattern is "orq $0x0,(%rsp)" for a probe in 64-bit mode.  */
-  if (signo == SIGSEGV && (pattern & 0xffffffffff) == 0x00240c8348)
+  if (signo == SIGSEGV && pc && (*pc & 0xffffffffff) == 0x00240c8348)
     mcontext->gregs[REG_RSP] += 4096 + 4 * sizeof (unsigned long);
 #elif defined (__ia64__)
   /* ??? The IA-64 unwinder doesn't compensate for signals.  */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-11-30 13:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-30 13:53 [Ada] Add missing guard in __gnat_adjust_context_for_raise Arnaud Charlet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).