From 94f4609c698a7c56821145570987c07ff1aeeaed Mon Sep 17 00:00:00 2001
From: Jeffrey Lee <me@phlamethrower.co.uk>
Date: Wed, 16 Dec 2020 19:53:04 +0000
Subject: [PATCH] Fix Service_ModeTranslation memory corruption

In HandleServiceModeTranslation, make sure WsPtr is initialised
correctly before trying to use it. Fixes system heap corruption when
responding to Service_ModeTranslation (most likely overwriting part of
ChocolateMABlocks, and causing a crash when loading future modules)

Fixes issue reported on forums:
https://www.riscosopen.org/forum/forums/11/topics/15973

Version 6.47. Tagged as 'Kernel-6_47'
---
 VersionASM        | 12 ++++++------
 VersionNum        | 20 ++++++++++----------
 s/vdu/legacymodes |  1 +
 3 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/VersionASM b/VersionASM
index 4a0e88b..fc675db 100644
--- a/VersionASM
+++ b/VersionASM
@@ -9,12 +9,12 @@
                         GBLS    Module_ApplicationDate
                         GBLS    Module_HelpVersion
                         GBLS    Module_ComponentName
-Module_MajorVersion     SETS    "6.46"
-Module_Version          SETA    646
+Module_MajorVersion     SETS    "6.47"
+Module_Version          SETA    647
 Module_MinorVersion     SETS    ""
-Module_Date             SETS    "23 Nov 2020"
-Module_ApplicationDate  SETS    "23-Nov-20"
+Module_Date             SETS    "19 Dec 2020"
+Module_ApplicationDate  SETS    "19-Dec-20"
 Module_ComponentName    SETS    "Kernel"
-Module_FullVersion      SETS    "6.46"
-Module_HelpVersion      SETS    "6.46 (23 Nov 2020)"
+Module_FullVersion      SETS    "6.47"
+Module_HelpVersion      SETS    "6.47 (19 Dec 2020)"
                         END
diff --git a/VersionNum b/VersionNum
index 52b8712..01a1e69 100644
--- a/VersionNum
+++ b/VersionNum
@@ -1,21 +1,21 @@
-/* (6.46)
+/* (6.47)
  *
  * This file is automatically maintained by srccommit, do not edit manually.
  *
  */
-#define Module_MajorVersion_CMHG        6.46
+#define Module_MajorVersion_CMHG        6.47
 #define Module_MinorVersion_CMHG
-#define Module_Date_CMHG                23 Nov 2020
+#define Module_Date_CMHG                19 Dec 2020
 
-#define Module_MajorVersion             "6.46"
-#define Module_Version                  646
+#define Module_MajorVersion             "6.47"
+#define Module_Version                  647
 #define Module_MinorVersion             ""
-#define Module_Date                     "23 Nov 2020"
+#define Module_Date                     "19 Dec 2020"
 
-#define Module_ApplicationDate          "23-Nov-20"
+#define Module_ApplicationDate          "19-Dec-20"
 
 #define Module_ComponentName            "Kernel"
 
-#define Module_FullVersion              "6.46"
-#define Module_HelpVersion              "6.46 (23 Nov 2020)"
-#define Module_LibraryVersionInfo       "6:46"
+#define Module_FullVersion              "6.47"
+#define Module_HelpVersion              "6.47 (19 Dec 2020)"
+#define Module_LibraryVersionInfo       "6:47"
diff --git a/s/vdu/legacymodes b/s/vdu/legacymodes
index 96cad88..ab35a96 100644
--- a/s/vdu/legacymodes
+++ b/s/vdu/legacymodes
@@ -805,6 +805,7 @@ HandleServiceModeTranslation ROUT
         STRNE   r8, [sp, #ModeSelector_FrameRate]
         ; Copy the mode selector block to TempModeSelector so we can safely
         ; return it.
+        VDWS    WsPtr
         ADD     r2, WsPtr, #TempModeSelector
         SUB     r1, r10, sp
 65
-- 
GitLab