From b7d04d848ddcae5cc412b794bea12bf7cc5df296 Mon Sep 17 00:00:00 2001
From: Lioncash <mathew1800@gmail.com>
Date: Mon, 19 Apr 2021 12:30:31 -0400
Subject: [PATCH 1/2] arp: Prevent uninitialized read of launch member variable

If anything happened to call arp functions in the wrong order and called
IRegistrar's Issue function before SetApplicationLaunchProperty, we'd
read from an uninitialized ApplicationLaunchProperty instance.

Instead, we can always initialize it so if this does happen, then the
outcome of doing such a thing is at least consistently reproducible.
---
 src/core/hle/service/glue/arp.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/core/hle/service/glue/arp.cpp b/src/core/hle/service/glue/arp.cpp
index 322125135f..e6d9d1b24a 100644
--- a/src/core/hle/service/glue/arp.cpp
+++ b/src/core/hle/service/glue/arp.cpp
@@ -240,7 +240,7 @@ private:
 
     std::function<ResultCode(u64, ApplicationLaunchProperty, std::vector<u8>)> issue_process_id;
     bool issued = false;
-    ApplicationLaunchProperty launch;
+    ApplicationLaunchProperty launch{};
     std::vector<u8> control;
 };
 

From 9f39f7c0411887a243739ff5ec3eafd7d2860323 Mon Sep 17 00:00:00 2001
From: Lioncash <mathew1800@gmail.com>
Date: Mon, 19 Apr 2021 12:36:08 -0400
Subject: [PATCH 2/2] arp: Use type alias for issue function

Reduces some verbosity and centralizes the function details in one spot.
---
 src/core/hle/service/glue/arp.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/core/hle/service/glue/arp.cpp b/src/core/hle/service/glue/arp.cpp
index e6d9d1b24a..7b1c6677ce 100644
--- a/src/core/hle/service/glue/arp.cpp
+++ b/src/core/hle/service/glue/arp.cpp
@@ -157,9 +157,9 @@ class IRegistrar final : public ServiceFramework<IRegistrar> {
     friend class ARP_W;
 
 public:
-    explicit IRegistrar(
-        Core::System& system_,
-        std::function<ResultCode(u64, ApplicationLaunchProperty, std::vector<u8>)> issuer)
+    using IssuerFn = std::function<ResultCode(u64, ApplicationLaunchProperty, std::vector<u8>)>;
+
+    explicit IRegistrar(Core::System& system_, IssuerFn&& issuer)
         : ServiceFramework{system_, "IRegistrar"}, issue_process_id{std::move(issuer)} {
         // clang-format off
         static const FunctionInfo functions[] = {
@@ -238,7 +238,7 @@ private:
         rb.Push(RESULT_SUCCESS);
     }
 
-    std::function<ResultCode(u64, ApplicationLaunchProperty, std::vector<u8>)> issue_process_id;
+    IssuerFn issue_process_id;
     bool issued = false;
     ApplicationLaunchProperty launch{};
     std::vector<u8> control;