Skip to content

Commit

Permalink
fix: fix unexpected end of string on eval
Browse files Browse the repository at this point in the history
  • Loading branch information
LazuliKao committed Jul 30, 2023
1 parent 75946d6 commit eebb682
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/Loader/CustomScriptLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ void LoadScript(string path)
}
catch (Exception ex)
{
Log.Logger.Error(nameof(LoadAllScripts), ex);
Log.Logger.Error(
nameof(LoadScript) + "('" + Path.GetRelativePath(pluginsDir, path) + "')",
ex
);
}
}
if (ScriptLoadRequest is null)
Expand Down
4 changes: 2 additions & 2 deletions src/QuickJS/Native.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,11 @@ internal static AutoDropJsValue JS_Eval(
)
{
fixed (byte* filePtr = StringUtils.StringToManagedUtf8(file))
fixed (byte* contentPtr = StringUtils.StringToManagedUtf8(content))
fixed (byte* contentPtr = StringUtils.StringToManagedUtf8(content, out var len))
{
var func = (delegate* unmanaged<JsContext*, byte*, size_t, byte*, int, JsValue>)
_ptrJsEval.Value;
var result = func(ctx, contentPtr, (size_t)content.Length, filePtr, (int)flags);
var result = func(ctx, contentPtr, (size_t)len, filePtr, (int)flags);
if (result.IsException())
{
ThrowPendingException(ctx);
Expand Down

0 comments on commit eebb682

Please sign in to comment.