From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8251 invoked by alias); 20 Mar 2014 17:31:28 -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 8240 invoked by uid 89); 20 Mar 2014 17:31:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Mar 2014 17:31:25 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2KHVOoN013143 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 20 Mar 2014 13:31:24 -0400 Received: from psique (ovpn-113-73.phx2.redhat.com [10.3.113.73]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s2KHVLiK014716 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 20 Mar 2014 13:31:23 -0400 From: Sergio Durigan Junior To: Daniel Gutson Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Small segfault fix when there is no python References: X-URL: http://www.redhat.com Date: Thu, 20 Mar 2014 17:31:00 -0000 In-Reply-To: (Daniel Gutson's message of "Thu, 20 Mar 2014 13:33:22 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-03/txt/msg00502.txt.bz2 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