From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14632 invoked by alias); 29 Jun 2007 04:35:39 -0000 Received: (qmail 14623 invoked by uid 22791); 29 Jun 2007 04:35:39 -0000 X-Spam-Check-By: sourceware.org Received: from a.mail.sonic.net (HELO a.mail.sonic.net) (64.142.16.245) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 29 Jun 2007 04:35:37 +0000 Received: from webmail.sonic.net (b.webmail.sonic.net [64.142.100.148]) by a.mail.sonic.net (8.13.8.Beta0-Sonic/8.13.7) with ESMTP id l5T4ZYGR010501 for ; Thu, 28 Jun 2007 21:35:35 -0700 Received: from 12.7.175.2 (SquirrelMail authenticated user msnyder) by webmail.sonic.net with HTTP; Thu, 28 Jun 2007 21:35:34 -0700 (PDT) Message-ID: <5313.12.7.175.2.1183091734.squirrel@webmail.sonic.net> Date: Fri, 29 Jun 2007 05:16:00 -0000 Subject: [resubmit] memory leak, mi-cmd-var From: msnyder@sonic.net To: gdb-patches@sourceware.org User-Agent: SquirrelMail/1.4.9a MIME-Version: 1.0 Content-Type: multipart/mixed;boundary="----=_20070628213534_92417" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-06/txt/msg00522.txt.bz2 ------=_20070628213534_92417 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Content-length: 580 After feedback from Nick Roberts -- it doesn't seem as if there is any reason for the strdup. I left the test for NULL in place, because I can't convince myself that it is un-necessary. Therefore the conservative approach is to leave it in. I've moved it to earlier so that if it's goint to error, we won't do unnecessary work. Version 1.1 of the file has this NULL check in it, right after the xstrdup. I would presume that Andrew Cagney would know that xstrdup won't return if it fails, so I can't explain the test away by saying he was just checking for xstrdup failure. ------=_20070628213534_92417 Content-Type: text/plain; name="formspec2.txt" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="formspec2.txt" Content-length: 1642 2007-06-28 Michael Snyder * mi/mi-cmd-var.c (mi_cmd_var_set_format): Eliminate unnecessary xstrdup. Index: mi/mi-cmd-var.c =================================================================== RCS file: /cvs/src/src/gdb/mi/mi-cmd-var.c,v retrieving revision 1.33 diff -p -r1.33 mi-cmd-var.c *** mi/mi-cmd-var.c 13 Jun 2007 19:08:47 -0000 1.33 --- mi/mi-cmd-var.c 29 Jun 2007 04:27:28 -0000 *************** mi_cmd_var_set_format (char *command, ch *** 203,218 **** if (argc != 2) error (_("mi_cmd_var_set_format: Usage: NAME FORMAT.")); /* Get varobj handle, if a valid var obj name was specified */ var = varobj_get_handle (argv[0]); if (var == NULL) error (_("mi_cmd_var_set_format: Variable object not found")); ! formspec = xstrdup (argv[1]); ! if (formspec == NULL) ! error (_("mi_cmd_var_set_format: Must specify the format as: \"natural\", \"binary\", \"decimal\", \"hexadecimal\", or \"octal\"")); ! len = strlen (formspec); if (strncmp (formspec, "natural", len) == 0) --- 203,218 ---- if (argc != 2) error (_("mi_cmd_var_set_format: Usage: NAME FORMAT.")); + if (argv[1] == NULL) + error (_("mi_cmd_var_set_format: Must specify the format as: \"natural\", \"binary\", \"decimal\", \"hexadecimal\", or \"octal\"")); + /* Get varobj handle, if a valid var obj name was specified */ var = varobj_get_handle (argv[0]); if (var == NULL) error (_("mi_cmd_var_set_format: Variable object not found")); ! formspec = argv[1]; len = strlen (formspec); if (strncmp (formspec, "natural", len) == 0) ------=_20070628213534_92417--