From f293664f8035dd5dcf89d9680131a4010dcbbed1 Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Fri, 13 Oct 2023 02:29:28 +0200
Subject: [PATCH] Fix saving of `storage` variable

---
 hwb1/src/hwb1/MyApplet.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hwb1/src/hwb1/MyApplet.java b/hwb1/src/hwb1/MyApplet.java
index 843f90f..a5c4ee9 100644
--- a/hwb1/src/hwb1/MyApplet.java
+++ b/hwb1/src/hwb1/MyApplet.java
@@ -21,7 +21,7 @@ import static hwb1.MyAppletStrings.*;
         // Insert your strings here
         name = "MyAppletStrings")
 public class MyApplet extends Applet {
-    private byte[] storage = null;
+    private byte[] storage = new byte[] {};
 
     /**
      * Installs this applet.
@@ -79,6 +79,7 @@ public class MyApplet extends Applet {
                     break;
                 case 0x02:
                     length = apdu.setIncomingAndReceive();
+                    storage = new byte[length];
 
                     if (length > 20) {
                         ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);