https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7320c989fe71a0e44db8c…
commit 7320c989fe71a0e44db8cfcdae245e123f156426
Author:     Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Tue Mar 2 14:38:36 2021 +0100
Commit:     Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Tue Mar 2 14:39:22 2021 +0100
    [WS2_32] Fix error handling on non-existing registry keys
---
 dll/win32/ws2_32/src/dcatalog.c | 11 +++++++++++
 dll/win32/ws2_32/src/nscatalo.c | 11 +++++++++++
 2 files changed, 22 insertions(+)
diff --git a/dll/win32/ws2_32/src/dcatalog.c b/dll/win32/ws2_32/src/dcatalog.c
index d91ec564349..c53e6c4faec 100644
--- a/dll/win32/ws2_32/src/dcatalog.c
+++ b/dll/win32/ws2_32/src/dcatalog.c
@@ -59,6 +59,17 @@ WsTcOpen(IN PTCATALOG Catalog,
                                 &RegType,
                                 NULL,
                                 &RegSize);
+    if (ErrorCode != ERROR_SUCCESS)
+    {
+        DPRINT1("Failed to get protocol catalog name: %d.\n", ErrorCode);
+        return FALSE;
+    }
+
+    if (RegType != REG_SZ)
+    {
+        DPRINT1("Protocol catalog name is not a string (Type %d).\n", RegType);
+        return FALSE;
+    }
     CatalogKeyName = HeapAlloc(WsSockHeap, 0, RegSize);
diff --git a/dll/win32/ws2_32/src/nscatalo.c b/dll/win32/ws2_32/src/nscatalo.c
index 6d32a4c8b7c..fe4d9cb28cf 100644
--- a/dll/win32/ws2_32/src/nscatalo.c
+++ b/dll/win32/ws2_32/src/nscatalo.c
@@ -58,6 +58,17 @@ WsNcOpen(IN PNSCATALOG Catalog,
                                 &RegType,
                                 NULL,
                                 &RegSize);
+    if (ErrorCode != ERROR_SUCCESS)
+    {
+        DPRINT1("Failed to get namespace catalog name: %d.\n", ErrorCode);
+        return FALSE;
+    }
+
+    if (RegType != REG_SZ)
+    {
+        DPRINT1("Namespace catalog name is not a string (Type %d).\n",
RegType);
+        return FALSE;
+    }
     CatalogKeyName = HeapAlloc(WsSockHeap, 0, RegSize);