From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2210) id AC9453857C61; Mon, 16 Nov 2020 13:40:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC9453857C61 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Ken Brown To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: path_conv::eq_worker: add NULL pointer checks X-Act-Checkin: newlib-cygwin X-Git-Author: Ken Brown X-Git-Refname: refs/heads/master X-Git-Oldrev: 140b0a6484414fcf848012c848c674644cc64f11 X-Git-Newrev: 22d1ebacfc5a1d3596d5dc25c2464fa51ed58944 Message-Id: <20201116134020.AC9453857C61@sourceware.org> Date: Mon, 16 Nov 2020 13:40:20 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 13:40:20 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=22d1ebacfc5a1d3596d5dc25c2464fa51ed58944 commit 22d1ebacfc5a1d3596d5dc25c2464fa51ed58944 Author: Ken Brown Date: Sat Nov 14 09:02:43 2020 -0500 Cygwin: path_conv::eq_worker: add NULL pointer checks Don't call cstrdup on NULL pointers. This fixes a crash that was observed when cloning an fhandler whose path_conv member had freed its strings. Diff: --- winsup/cygwin/path.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index b94f13df8..0b3e72fc1 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -320,9 +320,11 @@ class path_conv contrast to statically allocated strings. Calling device::dup() will duplicate the string if the source was allocated. */ dev.dup (); - path = cstrdup (in_path); + if (in_path) + path = cstrdup (in_path); conv_handle.dup (pc.conv_handle); - posix_path = cstrdup(pc.posix_path); + if (pc.posix_path) + posix_path = cstrdup(pc.posix_path); if (pc.wide_path) { wide_path = cwcsdup (uni_path.Buffer);