mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-24 16:11:43 +00:00
simd: fix scalar base64 empty input handling causing a crash
This commit is contained in:
@@ -53,9 +53,9 @@ fn decodeScalar(
|
||||
/// For non-SIMD enabled builds, we trim the padding from the end of the
|
||||
/// base64 input in order to get identical output with the SIMD version.
|
||||
fn scalarInput(input: []const u8) []const u8 {
|
||||
var i: usize = 0;
|
||||
while (input[input.len - i - 1] == '=') i += 1;
|
||||
return input[0 .. input.len - i];
|
||||
var end = input.len;
|
||||
while (end > 0 and input[end - 1] == '=') end -= 1;
|
||||
return input[0..end];
|
||||
}
|
||||
|
||||
// base64.cpp
|
||||
@@ -75,6 +75,14 @@ test "base64 maxLen" {
|
||||
try testing.expectEqual(11, len);
|
||||
}
|
||||
|
||||
test "base64 empty input" {
|
||||
const testing = std.testing;
|
||||
var output: [0]u8 = .{};
|
||||
|
||||
try testing.expectEqual(0, maxLen(""));
|
||||
try testing.expectEqualStrings("", try decode("", &output));
|
||||
}
|
||||
|
||||
test "base64 decode" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
|
||||
Reference in New Issue
Block a user