]> sourceware.org Git - newlib-cygwin.git/commitdiff
Fix memory leak in pthread_getattr_np
authorCorinna Vinschen <corinna@vinschen.de>
Wed, 21 Oct 2015 10:46:32 +0000 (12:46 +0200)
committerCorinna Vinschen <corinna@vinschen.de>
Thu, 22 Oct 2015 15:32:12 +0000 (17:32 +0200)
* thread.cc (pthread_getattr_np): Fix memory leak, remove usage of
malloc for small local buffer.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/ChangeLog
winsup/cygwin/release/2.3.0
winsup/cygwin/thread.cc

index b883cb40a735d465069d5ebece6aaba7448e6848..41a02efe91f93812fd13ab4decebba737f9a859b 100644 (file)
@@ -1,3 +1,8 @@
+2015-10-21  Corinna Vinschen  <corinna@vinschen.de>
+
+       * thread.cc (pthread_getattr_np): Fix memory leak, remove usage of
+       malloc for small local buffer.
+
 2015-10-21  Corinna Vinschen  <corinna@vinschen.de>
 
        * path.cc (symlink_info::check_reparse_point): Don't generate an EIO
index ad34671ad869042f4db4019999de60dee788bad0..ad5cfd001dac3238badde9fb22791785775b1a50 100644 (file)
@@ -42,3 +42,5 @@ Bug Fixes
 
 - Fix EIO error accessing certain (OS X SMB?) drives
   Addresses: https://cygwin.com/ml/cygwin/2015-09/msg00229.html
+
+- Fix memory leak in calls to pthread_getattr_np.
index b92a806204390fdc2a2e4ca2c82f7ca6e455bb87..d9b62111ff9c131c2f8a235d67e09ea3edf5b284 100644 (file)
@@ -2485,8 +2485,7 @@ pthread::resume (pthread_t *thread)
 extern "C" int
 pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
 {
-  const size_t sizeof_tbi = sizeof (THREAD_BASIC_INFORMATION);
-  PTHREAD_BASIC_INFORMATION tbi;
+  THREAD_BASIC_INFORMATION tbi;
   NTSTATUS status;
 
   if (!pthread::is_good_object (&thread))
@@ -2506,13 +2505,12 @@ pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
   (*attr)->schedparam = thread->attr.schedparam;
   (*attr)->guardsize = thread->attr.guardsize;
 
-  tbi = (PTHREAD_BASIC_INFORMATION) malloc (sizeof_tbi);
   status = NtQueryInformationThread (thread->win32_obj_id,
                                     ThreadBasicInformation,
-                                    tbi, sizeof_tbi, NULL);
+                                    &tbi, sizeof (tbi), NULL);
   if (NT_SUCCESS (status))
     {
-      PTEB teb = (PTEB) tbi->TebBaseAddress;
+      PTEB teb = (PTEB) tbi.TebBaseAddress;
       /* stackaddr holds the uppermost stack address.  See the comments
         in pthread_attr_setstack and pthread_attr_setstackaddr for a
         description. */
This page took 0.039756 seconds and 5 git commands to generate.