From cb8918d7cc028988bad79b66cbf577f2f37413e1 Mon Sep 17 00:00:00 2001
From: Eli Zaretskii <eliz@gnu.org>
Date: Sun, 30 Oct 2022 14:45:18 +0200
Subject: [PATCH] ; Fix unclean code in w32fns.c

* src/w32fns.c (setup_w32_kbdhook): Fix a typo and check errors
from the call to StringFromGUID2.  Reported by Juanma Barranquero
<lekktu@gmail.com>.
---
 src/w32fns.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/w32fns.c b/src/w32fns.c
index 5f652ae9e46..93b7f80f268 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -2734,8 +2734,7 @@ setup_w32_kbdhook (void)
 	  int i;
 
 	  CoCreateGuid (&guid);
-	  StringFromGUID2 (&guid, newTitle, 64);
-	  if (newTitle != NULL)
+	  if (oldTitle != NULL && StringFromGUID2 (&guid, newTitle, 64))
 	    {
 	      GetConsoleTitleW (oldTitle, 1024);
 	      SetConsoleTitleW (newTitle);
-- 
2.39.5