Revert "Merge pull request #18410 from dweiller/by-length-slice-bug"

This reverts commit d9d840a33a, reversing
changes made to a04d433094.

This is not an adequate implementation of the missing safety check, as
evidenced by the changes to std.json that are reverted in this commit.

Reopens #18382
Closes #18510
This commit is contained in:
Andrew Kelley
2024-01-13 23:20:33 -07:00
parent 0f9345ea9a
commit bd46410419
4 changed files with 0 additions and 76 deletions
-12
View File
@@ -402,33 +402,21 @@ pub fn innerParse(
},
.partial_string_escaped_1 => |arr| {
if (i + arr.len > r.len) return error.LengthMismatch;
// tell the compiler that the by-length slice below is valid;
// this assert is required for the inequality to be comptime-known
if (arr.len > r.len) unreachable;
@memcpy(r[i..][0..arr.len], arr[0..]);
i += arr.len;
},
.partial_string_escaped_2 => |arr| {
if (i + arr.len > r.len) return error.LengthMismatch;
// tell the compiler that the by-length slice below is valid;
// this assert is required for the inequality to be comptime-known
if (arr.len > r.len) unreachable;
@memcpy(r[i..][0..arr.len], arr[0..]);
i += arr.len;
},
.partial_string_escaped_3 => |arr| {
if (i + arr.len > r.len) return error.LengthMismatch;
// tell the compiler that the by-length slice below is valid;
// this assert is required for the inequality to be comptime-known
if (arr.len > r.len) unreachable;
@memcpy(r[i..][0..arr.len], arr[0..]);
i += arr.len;
},
.partial_string_escaped_4 => |arr| {
if (i + arr.len > r.len) return error.LengthMismatch;
// tell the compiler that the by-length slice below is valid;
// this assert is required for the inequality to be comptime-known
if (arr.len > r.len) unreachable;
@memcpy(r[i..][0..arr.len], arr[0..]);
i += arr.len;
},