From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25373 invoked by alias); 20 Mar 2014 17:52:42 -0000 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 Received: (qmail 25340 invoked by uid 89); 20 Mar 2014 17:52:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-vc0-f181.google.com Received: from mail-vc0-f181.google.com (HELO mail-vc0-f181.google.com) (209.85.220.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 20 Mar 2014 17:52:41 +0000 Received: by mail-vc0-f181.google.com with SMTP id id10so1360409vcb.26 for ; Thu, 20 Mar 2014 10:52:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=Q+3ehDCtTiDZ9AxJaau4+VRVXNXpT1f30jyWwiUBrvo=; b=AoKB6drDwQTA3IXCbt9M5UgCqer8UmACzX9NC46fUHMteXLd3pgOMhJMpCUlHXcWSB jkbhJB6YrndE0aT8BSOu63D1hSaqNp/AKTGiDVeJks8k0ROsGAfh4t5reZGC8cipceel HNRvnS8rgmXlkMiM709K5CAlXOE82HYH9PyW8aY4p9Jx6LpTGK/D1kCzqQ/PXQ22PbH+ qiSqEN9ls+IYydl3y7oLD9XzUBtEOKFVXu1JMuZbZ4Me7hht/DSWvYk0coIu537I/+Og 0lP0s3tPmETFZH7q1sYB2Y4okeOcdR4/Dyf1TaYE6SCDYyzRU3ByjsVCs72ZK5eostiH vNeg== X-Gm-Message-State: ALoCoQlWt5qKkL/Ss8xzSOSp8Fu3auUrGDbyDRR/NIsRp4sWkPtnkwHbWMpIT2xZTXCz+B1qz0f4iRpEWf55yVb2NTG4Y5jAz3D94IkJxQRGiF9IKArTfv6MB881XThCm6eDRiZ4mx1trS93QqJkYQVnBoZ5uPk2ZP1xHTvg7y3czxRKw5hRb1aWCZ6E7kaz7w7WwRApgXZkS6XSBCfJqQhSQYaBnDP04g== MIME-Version: 1.0 X-Received: by 10.52.163.145 with SMTP id yi17mr1187776vdb.46.1395337958644; Thu, 20 Mar 2014 10:52:38 -0700 (PDT) Received: by 10.52.13.101 with HTTP; Thu, 20 Mar 2014 10:52:38 -0700 (PDT) In-Reply-To: References: Date: Thu, 20 Mar 2014 17:52:00 -0000 Message-ID: Subject: Re: [PATCH] Small segfault fix when there is no python From: Doug Evans To: Sergio Durigan Junior Cc: Daniel Gutson , gdb-patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-03/txt/msg00503.txt.bz2 On Thu, Mar 20, 2014 at 10:31 AM, Sergio Durigan Junior wrote: > On Thursday, March 20 2014, Daniel Gutson wrote: > >> Hi, >> >> the small attached patch prevents gdb to segfault when an extension >> language definition has no ops, >> which e.g. occurs when HAVE_PYTHON is not defined so >> extension_language_python remains with ops in NULL. >> This causes the line >> if (extlang->ops->eval_from_control_command != NULL) >> (in eval_ext_lang_from_control_command) to dereference a null pointer. > > Hi Daniel, > > Thanks for the patch. This is a simple patch so it doesn't need a > copyright assignment from you. However, if you intend to continue > contributing to GDB, please e-mail me offlist and I can send you the > papers to obtain the assignment. > > Just a few comments about formatting issues. > >> 2014-03-20 Daniel Gutson (daniel.gutson@tallertechnologies.com) >> >> gdb/ >> * extension.c: (eval_ext_lang_from_control_command) Added check to >> prevent dereference of null pointer. > > The ChangeLog format is wrong. Take a look at the ChangeLog file for > lots of examples, but basically you need to write: > > 2014-03-20 Your Name > > * file.c (function): Added check to prevent blabla... > > Pay attention to the 2 spaces between the date, the name and the e-mail, > and also to the TAB character indenting the description. > >> diff --git a/gdb/extension.c b/gdb/extension.c >> index c2f502b..8357ee8 100644 >> --- a/gdb/extension.c >> +++ b/gdb/extension.c >> @@ -342,11 +342,14 @@ eval_ext_lang_from_control_command (struct command_line *cmd) >> { >> if (extlang->cli_control_type == cmd->control_type) >> { >> - if (extlang->ops->eval_from_control_command != NULL) >> - { >> - extlang->ops->eval_from_control_command (extlang, cmd); >> - return; >> - } >> + if (extlang->ops != NULL) >> + { >> + if (extlang->ops->eval_from_control_command != NULL) >> + { >> + extlang->ops->eval_from_control_command (extlang, cmd); >> + return; >> + } >> + } > > You could simplify this by writing: > > if (extlang->ops != NULL && extlang->ops->eval_from_control_command != NULL) > > If you don't want to join the two "if"s, then you don't need to put the > braces on the outter "if", because it has one single statement. > > The patch looks good to me, but I'm not a maintainer and can't approve > it. > > Thanks, > > -- > Sergio I did an audit of all the uses of ->ops and think this is the only one I missed. I will commit with the needed changes. Thanks for the patch!