[glib: 1/2] gthreadedresolver: Fix initialisation on FreeBSD



commit 6e7e5fff9a17b5f084d42c571cedbf26ae0361d1
Author: Philip Withnall <withnall endlessm com>
Date:   Mon Feb 25 11:22:45 2019 +0000

    gthreadedresolver: Fix initialisation on FreeBSD
    
    res_ninit() requires the __res_state struct passed to it to be
    zero-filled on FreeBSD.
    
    Spotted and analysed by Ashish SHUKLA.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    Fixes #1697

 gio/gthreadedresolver.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gio/gthreadedresolver.c b/gio/gthreadedresolver.c
index a6dd35c1b..9b7c396a1 100644
--- a/gio/gthreadedresolver.c
+++ b/gio/gthreadedresolver.c
@@ -940,8 +940,10 @@ do_lookup_records (GTask         *task,
    * What we have currently is not particularly worse than using res_query() in
    * worker threads, since it would transparently call res_init() for each new
    * worker thread. (Although the workers would get reused by the
-   * #GThreadPool.) */
-  struct __res_state res;
+   * #GThreadPool.)
+   *
+   * FreeBSD requires the state to be zero-filled before calling res_ninit(). */
+  struct __res_state res = { 0, };
   if (res_ninit (&res) != 0)
     {
       g_task_return_new_error (task, G_RESOLVER_ERROR, G_RESOLVER_ERROR_INTERNAL,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]