Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com Message-Id: <199904292008.PAA23228@modi.xraylith.wisc.edu> X-Authentication-Warning: modi.xraylith.wisc.edu: localhost.xraylith.wisc.edu [127.0.0.1] didn't use HELO protocol To: cygwin-developers AT sourceware DOT cygnus DOT com Subject: (patch) reg_key copy construction bug Date: Thu, 29 Apr 1999 15:08:36 -0500 From: Mumit Khan The following fix is hopefully obvious. Think of what happens when you pass a copy of a (open) reg_key to a function -- it calls the destructor on the way back, and so the does the original and RegClose crashes trying. The current implementation of reg_key is dangerous in that it blindly allows a copy construction; it should really disable copying by using a private copy. However that'll break the subkey generation, so it'll take a bit of rework. The current code should always crash in mount_info::from_registry () when Cygwin1.dll starts up. Against ss-1999-04-27. Thu Apr 29 13:55:57 1999 Mumit Khan * shared.h (read_mounts): Change prototype to accept a reference to reg_key, not a copy. * path.cc (read_mounts): Likewise. --- shared.h.~1 Thu Apr 29 13:51:51 1999 +++ shared.h Thu Apr 29 13:52:13 1999 @@ -335,7 +335,7 @@ public: private: void sort (); - void read_mounts (reg_key r); + void read_mounts (reg_key& r); void read_v1_mounts (reg_key r, const int which); void mount_slash (); void to_registry (); --- path.cc.~1 Thu Apr 29 13:55:20 1999 +++ path.cc Thu Apr 29 13:52:19 1999 @@ -1158,7 +1158,7 @@ mount_info::binary_win32_path_p (const c key. */ void -mount_info::read_mounts (reg_key r) +mount_info::read_mounts (reg_key& r) { HKEY key = r.get_key (); LONG err; Regards, Mumit