From patchwork Fri May 11 19:00:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 912126 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-477602-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=troutmask.apl.washington.edu Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="H39uCIe/"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40jKDp5vCpz9s16 for ; Sat, 12 May 2018 05:00:56 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=MtveQqaPaB1mn1UjOk6tEJIJ/1z5ci+dbFafFdKl5st X6b2qvnxrSuB2Qh4baGYQKpjfH3A72krkeJSE819xOhq8DKoaqbxif2aKfKwBRiF u0FuX1ZWCVbGxZ+f24XvAdsxJixkocLfS1zanmjDPZhWVTq/95aoKCsjfthN3SPU = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=vQirSD6C1zKNMwZ5GHqINBMmYJA=; b=H39uCIe/s0yRcQ9mz ad/sjLOl/d5Vf9qxadNdIXO1B5ow6U4l5BHHXe1NyF83r1SIJcloFVvvmhAJ21eE A7r+ZTcFkx/tPTB46PzksNas5GxyJHOil3B0PVOs3vs0s7G2Wo0vdBFtm3Z7ijRg cMFz2Ku9AqqpvOh9oKAFPAvRZ8= Received: (qmail 102354 invoked by alias); 11 May 2018 19:00:44 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 102224 invoked by uid 89); 11 May 2018 19:00:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-9.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=gfc_expr, Hx-languages-length:1339, UD:cl X-Spam-User: qpsmtpd, 2 recipients X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 May 2018 19:00:37 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id w4BJ0NYU067750 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 11 May 2018 12:00:23 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id w4BJ0NXG067749; Fri, 11 May 2018 12:00:23 -0700 (PDT) (envelope-from sgk) Date: Fri, 11 May 2018 12:00:23 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [Committed] PR fortran/85542 -- Avoid NULL dereference Message-ID: <20180511190023.GA67700@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) I've committed the attached patch. It checks for a valid pointer before using it. 2018-05-11 Steven G. Kargl PR fortran/85542 * expr.c (check_inquiry): Avoid NULL pointer dereference. 2018-05-11 Steven G. Kargl PR fortran/85542 * gfortran.dg/pr85542.f90: New test. Index: gcc/fortran/expr.c =================================================================== --- gcc/fortran/expr.c (revision 259653) +++ gcc/fortran/expr.c (working copy) @@ -2422,7 +2422,7 @@ check_inquiry (gfc_expr *e, int not_restricted) /* Assumed character length will not reduce to a constant expression with LEN, as required by the standard. */ - if (i == 5 && not_restricted + if (i == 5 && not_restricted && ap->expr->symtree && ap->expr->symtree->n.sym->ts.type == BT_CHARACTER && (ap->expr->symtree->n.sym->ts.u.cl->length == NULL || ap->expr->symtree->n.sym->ts.deferred)) Index: gcc/testsuite/gfortran.dg/pr85542.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr85542.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr85542.f90 (working copy) @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR fortran/85542 +function f(x) + character(*), intent(in) :: x + character((len((x)))) :: f + f = x +end