setMessage UAF / double-free on allocation failuresetMessage UAF / double-free on allocation failureFile: src/server/server.zig:299–303
Severity: MEDIUM
Status: ✅ FIXED — setMessage duplicates the new message first and only frees the old one on success. Regression test injects an allocation failure and verifies the previous message stays live and clearMessage frees exactly once.
pub fn setMessage(self: *Server, msg: []const u8) !void {
if (self.message) |m| self.allocator.free(m);
self.message = try self.allocator.dupe(u8, msg); // if dupe fails, self.message dangles
The old message is freed before the new one is duplicated. If dupe fails, self.message still points at freed memory. A subsequent clearMessage (305–310) frees it again (double free) and renderToDisplayClient (2447) reads it (UAF).