summaryrefslogtreecommitdiff
path: root/std/result.zc
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-19 22:48:04 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-19 22:48:04 +0000
commit23065ddf6ed0b3762dda5f5059888eb52b5c2415 (patch)
treeaec187b8211203081e8dacb07a5ce325eb348cc4 /std/result.zc
parent3af5dcf34d705cc52c1ffe5b85c2a90b5104e4c9 (diff)
Fixes related to memory safety. I will work more on this related to the stdlib.
Diffstat (limited to 'std/result.zc')
-rw-r--r--std/result.zc8
1 files changed, 7 insertions, 1 deletions
diff --git a/std/result.zc b/std/result.zc
index b043162..3794f1a 100644
--- a/std/result.zc
+++ b/std/result.zc
@@ -24,12 +24,18 @@ impl Result<T> {
return !self.is_ok;
}
+ fn forget(self) {
+ memset(&self.val, 0, sizeof(T));
+ }
+
fn unwrap(self) -> T {
if (!self.is_ok) {
!"Panic: unwrap called on Err: {self.err}";
exit(1);
}
- return self.val;
+ var v = self.val;
+ memset(&self.val, 0, sizeof(T));
+ return v;
}
fn expect(self, msg: char*) -> T {