Selaa lähdekoodia

Avoid SEGV in signal handler as second parameter is only a code, not a pointer

git-svn-id: trunk@20642 -
pierre 13 vuotta sitten
vanhempi
commit
6edb8a286f
1 muutettua tiedostoa jossa 9 lisäystä ja 2 poistoa
  1. 9 2
      rtl/netbsd/i386/sighnd.inc

+ 9 - 2
rtl/netbsd/i386/sighnd.inc

@@ -38,6 +38,7 @@ const
 procedure SignalToRunerror(Sig: longint;info : PSigInfo;SigContext: PSigContextRec); public name '_FPC_DEFAULTSIGHANDLER'; cdecl;
 
 var
+  code : ptruint;
   res,fpustate : word;
 begin
   res:=0;
@@ -49,14 +50,20 @@ begin
   end;
 {$endif cpui386}
 {$endif BSD}
+{$ifdef DEBUG}
+         Writeln(stderr,'Info is 0x',hexstr(ptruint(info),8));
+{$endif}
   case sig of
     SIGFPE :
           begin
     { this is not allways necessary but I don't know yet
       how to tell if it is or not PM }
           res:=200;
-          if assigned(info) then
-            fpustate:=info^._info.si_code
+          { In netbsd, the second parameter is a code, not a pointer to a siginfo structure
+            at least as long as we use sigaction14 }
+          code:=ptruint(info);
+          if code < high(fpustate) then
+            fpustate:=code
           else
             fpustate:=FPE_IntDiv;