Patchwork [Ada] Fix crash in gnatname due to uninitialized variable

login
register
mail settings
Submitter Arnaud Charlet
Date June 14, 2012, 10:46 a.m.
Message ID <20120614104625.GA15184@adacore.com>
Download mbox | patch
Permalink /patch/164908/
State New
Headers show

Comments

Arnaud Charlet - June 14, 2012, 10:46 a.m.
No functional change.

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

2012-06-14  Tristan Gingold  <gingold@adacore.com>

	* gnatname.adb (Gnatname): Make sure that dynamic table
	argument_data is initialized.

Patch

Index: gnatname.adb
===================================================================
--- gnatname.adb	(revision 188605)
+++ gnatname.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2001-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 2001-2012, 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- --
@@ -575,7 +575,15 @@ 
    --  Initialize tables
 
    Arguments.Set_Last (0);
-   Arguments.Increment_Last;
+   declare
+      New_Arguments : Argument_Data;
+      pragma Warnings (Off, New_Arguments);
+      --  Declaring this defaulted initialized object ensures
+      --  that the new allocated component of table Arguments
+      --  is correctly initialized.
+   begin
+      Arguments.Append (New_Arguments);
+   end;
    Patterns.Init (Arguments.Table (1).Directories);
    Patterns.Set_Last (Arguments.Table (1).Directories, 0);
    Patterns.Init (Arguments.Table (1).Name_Patterns);