Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/814829/?format=api
{ "id": 814829, "url": "http://patchwork.ozlabs.org/api/1.2/patches/814829/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20170918084834.GA20111@adacore.com/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/1.2/projects/17/?format=api", "name": "GNU Compiler Collection", "link_name": "gcc", "list_id": "gcc-patches.gcc.gnu.org", "list_email": "gcc-patches@gcc.gnu.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170918084834.GA20111@adacore.com>", "list_archive_url": null, "date": "2017-09-18T08:48:34", "name": "[Ada,PR,ada/71358] GNAT.Command_Line: crash in Getopt on empty Config", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "9f6755f37954d0fda793920ce2bbbb13b180a70c", "submitter": { "id": 64226, "url": "http://patchwork.ozlabs.org/api/1.2/people/64226/?format=api", "name": "Pierre-Marie de Rodat", "email": "derodat@adacore.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20170918084834.GA20111@adacore.com/mbox/", "series": [ { "id": 3589, "url": "http://patchwork.ozlabs.org/api/1.2/series/3589/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=3589", "date": "2017-09-18T08:48:34", "name": "[Ada,PR,ada/71358] GNAT.Command_Line: crash in Getopt on empty Config", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/3589/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/814829/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/814829/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<gcc-patches-return-462358-incoming=patchwork.ozlabs.org@gcc.gnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "mailing list gcc-patches@gcc.gnu.org" ], "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462358-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"g6GAnjxD\"; dkim-atps=neutral", "sourceware.org; auth=none" ], "Received": [ "from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xwfn95Wknz9s4s\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 18:49:01 +1000 (AEST)", "(qmail 24667 invoked by alias); 18 Sep 2017 08:48:39 -0000", "(qmail 24402 invoked by uid 89); 18 Sep 2017 08:48:38 -0000", "from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tMon, 18 Sep 2017 08:48:36 +0000", "from localhost (localhost.localdomain [127.0.0.1])\tby\n\tfiltered-rock.gnat.com (Postfix) with ESMTP id C6A13560D8;\n\tMon, 18 Sep 2017 04:48:34 -0400 (EDT)", "from rock.gnat.com ([127.0.0.1])\tby localhost (rock.gnat.com\n\t[127.0.0.1]) (amavisd-new, port 10024)\twith LMTP id\n\tWPCIBCxCm-Ir; Mon, 18 Sep 2017 04:48:34 -0400 (EDT)", "from tron.gnat.com (tron.gnat.com [205.232.38.10])\tby\n\trock.gnat.com (Postfix) with ESMTP id B4F90560E6;\n\tMon, 18 Sep 2017 04:48:34 -0400 (EDT)", "by tron.gnat.com (Postfix, from userid 4862)\tid B3F114FC;\n\tMon, 18 Sep 2017 04:48:34 -0400 (EDT)" ], "DomainKey-Signature": "a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:mime-version:content-type; q=dns;\n\ts=default; b=MMfppPp0XpvLvGKdAep3NjXbuchlpXMJ4J3iW6tzca5Nv8H4b1\n\t0JMNeCeH3XOJYt5S7LXee6aooFya5fDBr1m44eD3ga4fln3WfAds04Ok7otDfUHT\n\tri90thzxjVlBPylEz7L430srwiYjbOKLekGBxP0P06I4nu4JlohW2+gRM=", "DKIM-Signature": "v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:mime-version:content-type; s=\n\tdefault; bh=bv+CVn6/OzK2gTLxDrUoIZsd3B8=; b=g6GAnjxDNBo2J//gKA+C\n\tdf3c+FvnFYG9PEdObUMPSASBVXRrIeveVpqnQGhMD6e77jQEK+sFX77S3pVeRQxY\n\tYtwsErARFS7o0whQLxfmyNJhDJ4aOnya2LRMgYKG11KAHyYefEXiRiEz2jl0cYSR\n\tTxZfaal/oJBD8JXXNixgdbA=", "Mailing-List": "contact gcc-patches-help@gcc.gnu.org; run by ezmlm", "Precedence": "bulk", "List-Id": "<gcc-patches.gcc.gnu.org>", "List-Unsubscribe": "<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>", "List-Archive": "<http://gcc.gnu.org/ml/gcc-patches/>", "List-Post": "<mailto:gcc-patches@gcc.gnu.org>", "List-Help": "<mailto:gcc-patches-help@gcc.gnu.org>", "Sender": "gcc-patches-owner@gcc.gnu.org", "X-Virus-Found": "No", "X-Spam-SWARE-Status": "No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2,\n\tGIT_PATCH_3, RCVD_IN_DNSWL_NONE,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=", "X-HELO": "rock.gnat.com", "Date": "Mon, 18 Sep 2017 04:48:34 -0400", "From": "Pierre-Marie de Rodat <derodat@adacore.com>", "To": "gcc-patches@gcc.gnu.org", "Cc": "Bob Duff <duff@adacore.com>", "Subject": "[Ada][PR ada/71358] GNAT.Command_Line: crash in Getopt on empty\n\tConfig", "Message-ID": "<20170918084834.GA20111@adacore.com>", "MIME-Version": "1.0", "Content-Type": "multipart/mixed; boundary=\"LQksG6bCIzRHxTLp\"", "Content-Disposition": "inline", "User-Agent": "Mutt/1.5.23 (2014-03-12)", "X-IsSubscribed": "yes" }, "content": "This patch revisits the fix for a bug in GNAT.Command_Line.Getopt: instead of\nchecking everywhere that an pointer is not null, we allocate a dummy object and\nremove all null pointer checks.\n\nTested on x86_64-pc-linux-gnu, committed on trunk\n\n2017-09-18 Bob Duff <duff@adacore.com>\n\n\tAlternate fix for PR ada/71358\n\t* libgnat/g-comlin.adb (Getopt): Remove manual null access checks.\n\tInstead, make a local copy of Config, and if it's null, allocate an\n\tempty Command_Line_Configuration_Record, so we won't crash on null\n\tpointer dereference.", "diff": "Index: libgnat/g-comlin.adb\n===================================================================\n--- libgnat/g-comlin.adb\t(revision 252907)\n+++ libgnat/g-comlin.adb\t(working copy)\n@@ -3153,18 +3153,16 @@\n \n New_Line;\n \n- if Section /= \"\" and then Config.Switches /= null then\n+ if Section /= \"\" then\n Put_Line (\"Switches after \" & Section);\n end if;\n \n -- Compute size of the switches column\n \n- if Config.Switches /= null then\n- for S in Config.Switches'Range loop\n- Max_Len := Natural'Max\n- (Max_Len, Switch_Name (Config.Switches (S), Section)'Length);\n- end loop;\n- end if;\n+ for S in Config.Switches'Range loop\n+ Max_Len := Natural'Max\n+ (Max_Len, Switch_Name (Config.Switches (S), Section)'Length);\n+ end loop;\n \n if Config.Aliases /= null then\n for A in Config.Aliases'Range loop\n@@ -3177,28 +3175,26 @@\n \n -- Display the switches\n \n- if Config.Switches /= null then\n- for S in Config.Switches'Range loop\n- declare\n- N : constant String :=\n- Switch_Name (Config.Switches (S), Section);\n+ for S in Config.Switches'Range loop\n+ declare\n+ N : constant String :=\n+ Switch_Name (Config.Switches (S), Section);\n \n- begin\n- if N /= \"\" then\n- Put (\" \");\n- Put (N);\n- Put ((1 .. Max_Len - N'Length + 1 => ' '));\n+ begin\n+ if N /= \"\" then\n+ Put (\" \");\n+ Put (N);\n+ Put ((1 .. Max_Len - N'Length + 1 => ' '));\n \n- if Config.Switches (S).Help /= null then\n- Put (Config.Switches (S).Help.all);\n- end if;\n-\n- New_Line;\n+ if Config.Switches (S).Help /= null then\n+ Put (Config.Switches (S).Help.all);\n end if;\n- end;\n- end loop;\n- end if;\n \n+ New_Line;\n+ end if;\n+ end;\n+ end loop;\n+\n -- Display the aliases\n \n if Config.Aliases /= null then\n@@ -3348,6 +3344,7 @@\n Parser : Opt_Parser := Command_Line_Parser;\n Concatenate : Boolean := True)\n is\n+ Local_Config : Command_Line_Configuration := Config;\n Getopt_Switches : String_Access;\n C : Character := ASCII.NUL;\n \n@@ -3373,22 +3370,22 @@\n -- Do automatic handling when possible\n \n if Index /= -1 then\n- case Config.Switches (Index).Typ is\n+ case Local_Config.Switches (Index).Typ is\n when Switch_Untyped =>\n null; -- no automatic handling\n \n when Switch_Boolean =>\n- Config.Switches (Index).Boolean_Output.all :=\n- Config.Switches (Index).Boolean_Value;\n+ Local_Config.Switches (Index).Boolean_Output.all :=\n+ Local_Config.Switches (Index).Boolean_Value;\n return;\n \n when Switch_Integer =>\n begin\n if Parameter = \"\" then\n- Config.Switches (Index).Integer_Output.all :=\n- Config.Switches (Index).Integer_Default;\n+ Local_Config.Switches (Index).Integer_Output.all :=\n+ Local_Config.Switches (Index).Integer_Default;\n else\n- Config.Switches (Index).Integer_Output.all :=\n+ Local_Config.Switches (Index).Integer_Output.all :=\n Integer'Value (Parameter);\n end if;\n \n@@ -3402,8 +3399,8 @@\n return;\n \n when Switch_String =>\n- Free (Config.Switches (Index).String_Output.all);\n- Config.Switches (Index).String_Output.all :=\n+ Free (Local_Config.Switches (Index).String_Output.all);\n+ Local_Config.Switches (Index).String_Output.all :=\n new String'(Parameter);\n return;\n end case;\n@@ -3441,45 +3438,57 @@\n -- Start of processing for Getopt\n \n begin\n+ -- We work with a local copy of Config, because Config can be null, for\n+ -- example if Define_Switch was never called. We could modify Config\n+ -- itself, but then we would have to make it into an 'in out' parameter,\n+ -- which would be incompatible.\n+\n+ if Local_Config = null then\n+ Local_Config := new Command_Line_Configuration_Record;\n+ end if;\n+\n+ if Local_Config.Switches = null then\n+ Local_Config.Switches := new Switch_Definitions (1 .. 0);\n+ end if;\n+\n -- Initialize sections\n \n- if Config.Sections = null then\n- Config.Sections := new Argument_List'(1 .. 0 => null);\n+ if Local_Config.Sections = null then\n+ Local_Config.Sections := new Argument_List'(1 .. 0 => null);\n end if;\n \n Internal_Initialize_Option_Scan\n (Parser => Parser,\n Switch_Char => Parser.Switch_Character,\n Stop_At_First_Non_Switch => Parser.Stop_At_First,\n- Section_Delimiters => Section_Delimiters (Config));\n+ Section_Delimiters => Section_Delimiters (Local_Config));\n \n Getopt_Switches := new String'\n- (Get_Switches (Config, Parser.Switch_Character, Section_Name.all)\n+ (Get_Switches (Local_Config, Parser.Switch_Character, Section_Name.all)\n & \" h -help\");\n \n -- Initialize output values for automatically handled switches\n \n- if Config.Switches /= null then\n- for S in Config.Switches'Range loop\n- case Config.Switches (S).Typ is\n- when Switch_Untyped =>\n- null; -- Nothing to do\n+ for S in Local_Config.Switches'Range loop\n+ case Local_Config.Switches (S).Typ is\n+ when Switch_Untyped =>\n+ null; -- Nothing to do\n \n- when Switch_Boolean =>\n- Config.Switches (S).Boolean_Output.all :=\n- not Config.Switches (S).Boolean_Value;\n+ when Switch_Boolean =>\n+ Local_Config.Switches (S).Boolean_Output.all :=\n+ not Local_Config.Switches (S).Boolean_Value;\n \n- when Switch_Integer =>\n- Config.Switches (S).Integer_Output.all :=\n- Config.Switches (S).Integer_Initial;\n+ when Switch_Integer =>\n+ Local_Config.Switches (S).Integer_Output.all :=\n+ Local_Config.Switches (S).Integer_Initial;\n \n- when Switch_String =>\n- if Config.Switches (S).String_Output.all = null then\n- Config.Switches (S).String_Output.all := new String'(\"\");\n- end if;\n- end case;\n- end loop;\n- end if;\n+ when Switch_String =>\n+ if Local_Config.Switches (S).String_Output.all = null then\n+ Local_Config.Switches (S).String_Output.all :=\n+ new String'(\"\");\n+ end if;\n+ end case;\n+ end loop;\n \n -- For all sections, and all switches within those sections\n \n@@ -3500,34 +3509,34 @@\n or else\n Full_Switch (Parser) = \"-help\"\n then\n- Display_Help (Config);\n+ Display_Help (Local_Config);\n raise Exit_From_Command_Line;\n end if;\n \n -- Do switch expansion if needed\n \n For_Each_Simple\n- (Config,\n+ (Local_Config,\n Section => Section_Name.all,\n Switch => Parser.Switch_Character & Full_Switch (Parser),\n Parameter => Parameter (Parser));\n \n else\n if Current_Section = -1 then\n- Current_Section := Config.Sections'First;\n+ Current_Section := Local_Config.Sections'First;\n else\n Current_Section := Current_Section + 1;\n end if;\n \n- exit when Current_Section > Config.Sections'Last;\n+ exit when Current_Section > Local_Config.Sections'Last;\n \n- Section_Name := Config.Sections (Current_Section);\n+ Section_Name := Local_Config.Sections (Current_Section);\n Goto_Section (Section_Name.all, Parser);\n \n Free (Getopt_Switches);\n Getopt_Switches := new String'\n (Get_Switches\n- (Config, Parser.Switch_Character, Section_Name.all));\n+ (Local_Config, Parser.Switch_Character, Section_Name.all));\n end if;\n end loop;\n \n", "prefixes": [ "Ada", "PR", "ada/71358" ] }