Fix handling of null returned from _runRules
authorMiloslav Trmač <mitr@redhat.com>
Thu, 18 Apr 2013 18:31:48 +0000 (20:31 +0200)
committerMiloslav Trmač <mitr@redhat.com>
Mon, 6 May 2013 17:57:03 +0000 (19:57 +0200)
https://bugs.freedesktop.org/show_bug.cgi?id=63575

src/polkitbackend/polkitbackendjsauthority.c

index 3eeca21436dd966a121d907c6b5253b5eec1a1a0..0dd95481f9dd950aa2a0f005c035f1f9c536add5 100644 (file)
@@ -1188,20 +1188,20 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu
       goto out;
     }
 
-  if (!JSVAL_IS_STRING (rval) && !JSVAL_IS_NULL (rval))
+  if (JSVAL_IS_NULL (rval))
     {
-      g_warning ("Expected a string");
+      /* this fine, means there was no match, use implicit authorizations */
+      good = TRUE;
       goto out;
     }
 
-  ret_jsstr = JSVAL_TO_STRING (rval);
-  if (ret_jsstr == NULL)
+  if (!JSVAL_IS_STRING (rval))
     {
-      /* this fine, means there was no match, use implicit authorizations */
-      good = TRUE;
+      g_warning ("Expected a string");
       goto out;
     }
 
+  ret_jsstr = JSVAL_TO_STRING (rval);
   ret_utf16 = JS_GetStringCharsZ (authority->priv->cx, ret_jsstr);
   ret_str = g_utf16_to_utf8 (ret_utf16, -1, NULL, NULL, &error);
   if (ret_str == NULL)