diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c
index 6d69cf97d96591ef4480e0c5e49f78f86d9f8082..b3525953e3d783b760ff2d237d3dcbf7e19ccfed 100644
--- a/dlls/msi/msi.c
+++ b/dlls/msi/msi.c
@@ -1272,13 +1272,17 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
     if (!components)
         return INSTALLSTATE_ADVERTISED;
 
-    for( p = components; *p != 2 ; p += 20)
+    for( p = components; *p && *p != 2 ; p += 20)
     {
         if (!decode_base85_guid( p, &guid ))
         {
-            ERR("%s\n", debugstr_w(p));
-            break;
+            if (p != components)
+                break;
+
+            msi_free(components);
+            return INSTALLSTATE_BADCONFIG;
         }
+
         StringFromGUID2(&guid, comp, GUID_SIZE);
         r = MsiGetComponentPathW(szProduct, comp, NULL, 0);
         TRACE("component %s state %d\n", debugstr_guid(&guid), r);
diff --git a/dlls/msi/tests/msi.c b/dlls/msi/tests/msi.c
index 589b161c9052343b372be5e7f1baeb20b2761e47..78145719ea1e5c0df63f0e1b33ed1eb60934d62a 100644
--- a/dlls/msi/tests/msi.c
+++ b/dlls/msi/tests/msi.c
@@ -591,10 +591,7 @@ static void test_MsiQueryFeatureState(void)
     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
 
     state = MsiQueryFeatureStateA(prodcode, "feature");
-    todo_wine
-    {
-        ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state);
-    }
+    ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state);
 
     res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaa", 21);
     ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);