From efd491c0e37502024538827c1ce455ea46f18a82 Mon Sep 17 00:00:00 2001 From: Evengard Date: Tue, 14 Feb 2023 12:00:20 +0300 Subject: [PATCH] Another NullReferenceException quick fixup --- plugins/mono/mono_plugin.c | 4 ++-- plugins/mono/uwsgi.cs | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/plugins/mono/mono_plugin.c b/plugins/mono/mono_plugin.c index 3ddb1df5a..857f3ee6b 100644 --- a/plugins/mono/mono_plugin.c +++ b/plugins/mono/mono_plugin.c @@ -163,7 +163,7 @@ static MonoString *uwsgi_mono_method_GetUriPath(MonoObject *this) { return uwsgi_mono_method_GetFilePathInt(this); } -static MonoString *uwsgi_mono_method_MapPath(MonoObject *this, MonoString *virtualPath) { +static MonoString *uwsgi_mono_method_MapPathInt(MonoObject *this, MonoString *virtualPath) { struct wsgi_request *wsgi_req = uwsgi_mono_get_current_req(this); struct uwsgi_app *app = &uwsgi_apps[wsgi_req->app_id]; char *path = uwsgi_concat3n(app->interpreter, strlen(app->interpreter), "/", 1, mono_string_to_utf8(virtualPath), mono_string_length(virtualPath)); @@ -321,7 +321,7 @@ static void uwsgi_mono_add_internal_calls() { mono_add_internal_call("uwsgi.uWSGIRequest::SendUnknownResponseHeader", uwsgi_mono_method_SendUnknownResponseHeader); mono_add_internal_call("uwsgi.uWSGIRequest::FlushResponse", uwsgi_mono_method_FlushResponse); mono_add_internal_call("uwsgi.uWSGIRequest::GetQueryString", uwsgi_mono_method_GetQueryString); - mono_add_internal_call("uwsgi.uWSGIRequest::MapPath", uwsgi_mono_method_MapPath); + mono_add_internal_call("uwsgi.uWSGIRequest::MapPathInt", uwsgi_mono_method_MapPathInt); mono_add_internal_call("uwsgi.uWSGIRequest::GetHttpVerbName", uwsgi_mono_method_GetHttpVerbName); mono_add_internal_call("uwsgi.uWSGIRequest::GetRawUrl", uwsgi_mono_method_GetRawUrl); mono_add_internal_call("uwsgi.uWSGIRequest::GetFilePathInt", uwsgi_mono_method_GetFilePathInt); diff --git a/plugins/mono/uwsgi.cs b/plugins/mono/uwsgi.cs index 924eddc87..2d10ed963 100644 --- a/plugins/mono/uwsgi.cs +++ b/plugins/mono/uwsgi.cs @@ -104,7 +104,17 @@ public override string GetFilePath() extern private string GetFilePathInt(); [MethodImplAttribute(MethodImplOptions.InternalCall)] - extern public override string MapPath(string virtualPath); + extern private string MapPathInt(string virtualPath); + + public override string MapPath(string virtualPath) + { + string mpath = MapPathInt(virtualPath) + if (mpath == null) + { + return GetFilePath(); + } + return mpath; + } public override void EndOfRequest() { _requestEndEvent.Set();