[glib] gthread: Fix use of a local variable after it went out of scope
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gthread: Fix use of a local variable after it went out of scope
- Date: Tue, 20 May 2014 10:01:56 +0000 (UTC)
commit 03a82ce898ea435efd73a250d989f8dc6249aaf8
Author: Philip Withnall <philip withnall collabora co uk>
Date: Fri May 16 21:47:24 2014 +0100
gthread: Fix use of a local variable after it went out of scope
This could theoretically cause problems, although in practice we would
have seen them by now (the bug was introduced in 2012).
Coverity issue: #1159486
https://bugzilla.gnome.org/show_bug.cgi?id=730277
glib/gthread-posix.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index c98c2d8..2f54070 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -83,18 +83,18 @@ g_mutex_impl_new (void)
pthread_mutexattr_t *pattr = NULL;
pthread_mutex_t *mutex;
gint status;
+#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
+ pthread_mutexattr_t attr;
+#endif
mutex = malloc (sizeof (pthread_mutex_t));
if G_UNLIKELY (mutex == NULL)
g_thread_abort (errno, "malloc");
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
- {
- pthread_mutexattr_t attr;
- pthread_mutexattr_init (&attr);
- pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
- pattr = &attr;
- }
+ pthread_mutexattr_init (&attr);
+ pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
+ pattr = &attr;
#endif
if G_UNLIKELY ((status = pthread_mutex_init (mutex, pattr)) != 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]