Patchwork [Ada] Bad initialization of dynamic tables in gnatname ... --and ...

login
register
mail settings
Submitter Arnaud Charlet
Date June 18, 2010, 2:19 p.m.
Message ID <20100618141942.GA5325@adacore.com>
Download mbox | patch
Permalink /patch/56192/
State New
Headers show

Comments

Arnaud Charlet - June 18, 2010, 2:19 p.m.
Dynamic tables in the implementation of gnatname when switch --and is
used were not properly initialized. This patch ensures that they are.
There is no known simple test for this.

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

2010-06-18  Vincent Celier  <celier@adacore.com>

	* gnatname.adb (Scan_Args): When --and is used, make sure that the
	dynamic tables in the newly allocated Argument_Data are properly
	initialized.

Patch

Index: gnatname.adb
===================================================================
--- gnatname.adb	(revision 160959)
+++ gnatname.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2001-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 2001-2010, Free Software Foundation, Inc.         --
 --                                                                          --
 -- 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- --
@@ -306,7 +306,16 @@  procedure Gnatname is
 
                   --  Add and initialize another component to Arguments table
 
-                  Arguments.Increment_Last;
+                  declare
+                     New_Arguments : Argument_Data;
+                     pragma Warnings (Off, New_Arguments);
+                     --  Declaring this defaulted itialized object ensures that
+                     --  the new allocated component of table Arguments is
+                     --  correctly initialized.
+
+                  begin
+                     Arguments.Append (New_Arguments);
+                  end;
 
                   Patterns.Init
                     (Arguments.Table (Arguments.Last).Directories);