From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 50951 invoked by alias); 7 Aug 2018 01:06:01 -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 50938 invoked by uid 89); 7 Aug 2018 01:06:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-spam-relays-external:ESMTPA X-HELO: mailer.thelig.ht Received: from mailer.thelig.ht (HELO mailer.thelig.ht) (18.221.98.147) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 07 Aug 2018 01:05:58 +0000 Received: from roundcube-server (localhost [127.0.0.1]) (Authenticated sender: rian@thelig.ht) by email-server.localdomain (Postfix) with ESMTPA id 807F6499A16 for ; Mon, 6 Aug 2018 18:05:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thelig.ht; s=dkim; t=1533603956; bh=2eRbnzMZ8ZjVwzp7mScZaXWQOEPWTxNBcvyPf1JiEgY=; h=Date:From:To:Subject:From; b=eiJmRbmm4lhCEeJFGIUu10Cey77jI9rZMWRkDR8mubDHO759oG3GZrIi+pa3ykuVu gP/A+PmZ60srO6K4+hrg3lSSYkFi9ekiek7rzMVvQOepC4fjji/eNv0Qq9a5kqP4HM mSlgFxUIEUWUFCa62gPzUAdtqvtPpK70TknbMWSk= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 07 Aug 2018 01:06:00 -0000 From: Rian Hunter To: gdb-patches@sourceware.org Subject: fix invalid memory references in gdb/jit.c Message-ID: <8ff4437eb869559c2f917dcb49d3cacd@thelig.ht> X-Sender: rian@thelig.ht User-Agent: Roundcube Webmail/1.1.4 X-SW-Source: 2018-08/txt/msg00108.txt.bz2 These patches fix the case where calling block_open() non-1 amount of times causes seg faults. This is when using the custom jit reader API. diff --git a/gdb/jit.c b/gdb/jit.c index e6b3cc25ca..78295f0dc2 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -684,8 +684,11 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) /* (begin, end) will contain the PC range this entire blockvector spans. */ BLOCKVECTOR_MAP (bv) = NULL; - begin = stab->blocks->begin; - end = stab->blocks->end; + if (stab->blocks) + { + begin = stab->blocks->begin; + end = stab->blocks->end; + } BLOCKVECTOR_NBLOCKS (bv) = actual_nblocks; /* First run over all the gdb_block objects, creating a real block @@ -780,7 +783,8 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) for (gdb_block_iter = stab->blocks, gdb_block_iter_tmp = gdb_block_iter->next; gdb_block_iter; - gdb_block_iter = gdb_block_iter_tmp) + gdb_block_iter = gdb_block_iter_tmp, + gdb_block_iter_tmp = (gdb_block_iter ? gdb_block_iter->next : NULL)) { xfree ((void *) gdb_block_iter->name); xfree (gdb_block_iter);