[glib-networking] gnutls: Fix use of undefined variables on early cancellation
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking] gnutls: Fix use of undefined variables on early cancellation
- Date: Thu, 11 Jan 2018 10:47:01 +0000 (UTC)
commit eb24905fece641194bad91e8fe6e073dd324023a
Author: Philip Withnall <withnall endlessm com>
Date: Wed Jan 10 11:53:06 2018 +0000
gnutls: Fix use of undefined variables on early cancellation
If a claim_op() operation is cancelled before entering its blocking
while loop, the value of `result` would be undefined, which is bad.
Initialise `result` to a value which imitates what would happen had the
while loop been iterated and *then* cancelled.
Coverity CID: 249792
Signed-off-by: Philip Withnall <withnall endlessm com>
https://bugzilla.gnome.org/show_bug.cgi?id=792402
tls/gnutls/gtlsconnection-gnutls.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index 2579fa5..9c7d387 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -740,7 +740,7 @@ claim_op (GTlsConnectionGnutls *gnutls,
GPollFD fds[2];
int nfds;
gint64 start_time;
- gint result;
+ gint result = 1; /* if the loop is never entered, it’s as if we cancelled early */
g_cancellable_reset (gnutls->priv->waiting_for_op);
@@ -1330,7 +1330,7 @@ g_tls_connection_gnutls_condition_wait (GDatagramBased *datagram_based,
GTlsConnectionGnutls *gnutls = G_TLS_CONNECTION_GNUTLS (datagram_based);
GPollFD fds[2];
guint n_fds;
- gint result;
+ gint result = 1; /* if the loop is never entered, it’s as if we cancelled early */
gint64 start_time;
if (g_cancellable_set_error_if_cancelled (cancellable, error))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]