summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Brown <kbrown@cornell.edu>2020-11-14 09:02:43 -0500
committerKen Brown <kbrown@cornell.edu>2020-11-16 08:15:31 -0500
commit22d1ebacfc5a1d3596d5dc25c2464fa51ed58944 (patch)
treedc2d80b5f46226eb9115e7ea317b51aaff955321
parent140b0a6484414fcf848012c848c674644cc64f11 (diff)
downloadcygnal-22d1ebacfc5a1d3596d5dc25c2464fa51ed58944.tar.gz
cygnal-22d1ebacfc5a1d3596d5dc25c2464fa51ed58944.tar.bz2
cygnal-22d1ebacfc5a1d3596d5dc25c2464fa51ed58944.zip
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.
-rw-r--r--winsup/cygwin/path.h6
1 files 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);