Patchwork [Ada] Fix potential access violation in Adjust routine

login
register
mail settings
Submitter Arnaud Charlet
Date July 17, 2012, 10:14 a.m.
Message ID <20120717101446.GA25870@adacore.com>
Download mbox | patch
Permalink /patch/171385/
State New
Headers show

Comments

Arnaud Charlet - July 17, 2012, 10:14 a.m.
Tested on x86_64-pc-linux-gnu, committed on trunk

2012-07-17  Pascal Obry  <obry@adacore.com>

	* s-regexp.adb (Adjust): Fix access violation in Adjust.

Patch

Index: s-regexp.adb
===================================================================
--- s-regexp.adb	(revision 189565)
+++ s-regexp.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                     Copyright (C) 1999-2010, AdaCore                     --
+--                     Copyright (C) 1999-2012, AdaCore                     --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -100,10 +100,12 @@ 
       Tmp : Regexp_Access;
 
    begin
-      Tmp := new Regexp_Value (Alphabet_Size => R.R.Alphabet_Size,
-                               Num_States    => R.R.Num_States);
-      Tmp.all := R.R.all;
-      R.R := Tmp;
+      if R.R /= null then
+         Tmp := new Regexp_Value (Alphabet_Size => R.R.Alphabet_Size,
+                                  Num_States    => R.R.Num_States);
+         Tmp.all := R.R.all;
+         R.R := Tmp;
+      end if;
    end Adjust;
 
    -------------