PolicyKit: Branch 'master'
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Apr 7 12:30:55 UTC 2022
src/polkitbackend/polkitbackendjsauthority.cpp | 31 ++-----------------------
1 file changed, 3 insertions(+), 28 deletions(-)
New commits:
commit 56bde409579052c3c5c1f4372cd9c3782845b807
Author: Xi Ruoyao <xry111 at mengyan1223.wang>
Date: Thu Apr 7 12:30:53 2022 +0000
jsauthority: use JS::CompileUtf8Path instead of custom code reading file
diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
index 660407f..2568e8e 100644
--- a/src/polkitbackend/polkitbackendjsauthority.cpp
+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
@@ -216,39 +216,16 @@ load_scripts (PolkitBackendJsAuthority *authority)
for (l = files; l != NULL; l = l->next)
{
const gchar *filename = (gchar *)l->data;
- GFile *file = g_file_new_for_path (filename);
- char *contents;
- gsize len;
- if (!g_file_load_contents (file, NULL, &contents, &len, NULL, NULL))
- {
- polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
- "Error compiling script %s",
- filename);
- g_object_unref (file);
- continue;
- }
-
- g_object_unref (file);
-
- JS::SourceText<mozilla::Utf8Unit> source;
- if (!source.init (authority->priv->cx, contents, len,
- JS::SourceOwnership::Borrowed))
- {
- polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
- "Error compiling script %s",
- filename);
- g_free (contents);
- continue;
- }
JS::CompileOptions options(authority->priv->cx);
JS::RootedScript script(authority->priv->cx,
- JS::Compile (authority->priv->cx, options, source));
+ JS::CompileUtf8Path (authority->priv->cx,
+ options,
+ filename));
if (!script)
{
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
"Error compiling script %s",
filename);
- g_free (contents);
continue;
}
@@ -261,13 +238,11 @@ load_scripts (PolkitBackendJsAuthority *authority)
polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
"Error executing script %s",
filename);
- g_free (contents);
continue;
}
//g_print ("Successfully loaded and evaluated script `%s'\n", filename);
- g_free (contents);
num_scripts++;
}
More information about the hal-commit
mailing list