[glib/wip/baedert/timezone] timezone: Initialize a local variable




commit 6c3f367d2c3befbd6a294ed36ec3b25ddb8ebf90
Author: Timm Bäder <mail baedert org>
Date:   Sat Aug 1 09:10:50 2020 +0200

    timezone: Initialize a local variable
    
    There is a "goto utf16_conv_failed" before in case subkey_w is NULL.
    In that case, we're calling g_free() on uninitialized memory.
    
    Fixes this compiler warning:
    
    ../subprojects/glib/glib/gtimezone.c:979:3: error: 'subkey_dynamic_w' may be used uninitialized in this 
function [-Werror=maybe-uninitialized]
      979 |   g_free (subkey_dynamic_w);
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~
    
    Found in the gtk windows build.

 glib/gtimezone.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/glib/gtimezone.c b/glib/gtimezone.c
index 7c1187371..8ee6186d7 100644
--- a/glib/gtimezone.c
+++ b/glib/gtimezone.c
@@ -829,7 +829,7 @@ rules_from_windows_time_zone (const gchar   *identifier,
   guint rules_num = 0;
   RegTZI regtzi, regtzi_prev;
   WCHAR winsyspath[MAX_PATH];
-  gunichar2 *subkey_w, *subkey_dynamic_w;
+  gunichar2 *subkey_w, *subkey_dynamic_w = NULL;
 
   if (GetSystemDirectoryW (winsyspath, MAX_PATH) == 0)
     return 0;


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