Commit Graph

1096 Commits

Author SHA1 Message Date
user.name
6ccde7f80b bugfix: core/encoding/json leaks the key and value of a malformed object
parse_object_body allocates an object key, then may fail in parse_colon or
parse_value before that key is ever inserted into the object. Its cleanup defer
only walks `obj`, so a key that never got there is unreachable to it. The caller
cannot free it either -- a failed parse returns a nil Value -- so it leaks.

The same applies to the parsed element on the duplicate-key path, and to both on
the out-of-memory path.

JSON5 makes this reachable from ordinary malformed input, because an unquoted
ident is a legal key and anything other than a colon after it fails. Plain JSON
leaks it too, via a quoted key.

before, measured with a tracking allocator over 8 inputs x 2 specs:

	LEAK JSON5  colon fails after unquoted key   1 alloc / 7 bytes
	LEAK JSON   colon fails after quoted key     1 alloc / 2 bytes
	LEAK JSON5  colon fails after quoted key     1 alloc / 2 bytes
	LEAK JSON   value fails after key            1 alloc / 2 bytes
	LEAK JSON5  value fails after key            1 alloc / 2 bytes
	LEAK JSON   nested value fails               2 alloc / 4 bytes
	LEAK JSON5  nested value fails               2 alloc / 4 bytes
	LEAK JSON   deep nesting fails               3 alloc / 6 bytes
	LEAK JSON5  deep nesting fails               3 alloc / 6 bytes
	LEAK JSON   array element fails              1 alloc / 2 bytes
	LEAK JSON5  array element fails              1 alloc / 2 bytes
	total leaked allocations: 17

after, same probe:

	total leaked allocations: 0

The leak scales with nesting depth -- one orphaned key per enclosing object -- so
a service parsing untrusted JSON leaks a little on every malformed request.

The fix marks the key and the element as owned by the loop iteration until they
are stored, and frees them otherwise. The duplicate-key path loses its explicit
delete, which the same mechanism now covers.

Found via odinfmt, which reported a 7-byte leak in a downstream test that parses
`{ broken not json` to check that invalid input is rejected.

Regression test added to tests/core/encoding/json: it reports
`17 leaks and 0 bad frees` without this change and passes with it. The existing
11 tests pass unchanged under -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true.
2026-08-31 11:39:42 -07:00
Jeroen van Rijn
de2b46961a Merge pull request #7468 from mac119/fix-7421-tagless-switch-duplicate-cases
checker: Do not deduplicate cases in tagless switches
2026-08-31 04:06:08 -07:00
thetarnav
db2f88cff9 Improve parsing field docs and comments (fixes #5353) 2026-08-29 19:22:18 +02:00
leo119
24cb1abf29 checker: Do not deduplicate cases in tagless switches
Tagless switch cases are ordered predicates, so distinct constant conditions may fold to the same Boolean value. Restrict duplicate-case tracking to explicitly tagged switches and add positive and negative regression coverage for issue #7421.
2026-08-27 14:53:54 +08:00
Jeroen van Rijn
9909676141 Merge pull request #7462 from MoonlightChase/fix-grapheme-width
This Fixes #5939 , where many characters like flags are reported with…
2026-08-26 06:14:30 -07:00
MoonlightChase
556bdb0056 This Fixes #5939 , where many characters like flags are reported with width 1 even though their width is 2. Country glags need additional special case also since RI letters are EAW neutral and not Wide.
i was working on this when i stumbled on this bug, so i did bunch of different characters to see which ones cause issue, hence test has many different options. I could make it either simpler or split it, as needed.
2026-08-26 13:31:43 +02:00
Jeroen van Rijn
4da9d4a01e Add tests/abi/build to .gitignore 2026-08-26 13:02:56 +02:00
Jeroen van Rijn
6a83f08c8b Fix justified printing of 0 producing all spaces. 2026-08-26 12:11:38 +02:00
gingerBill
34643f30d9 Merge branch 'master' into const_array_broadcast 2026-08-26 08:45:51 +01:00
gingerBill
d06ac2fe64 Merge pull request #7428 from mocompute/check-7336
add regression test for #7336
2026-08-26 08:43:06 +01:00
gingerBill
dcb66ab09d Merge branch 'master' into const_array_broadcast 2026-08-26 08:42:51 +01:00
gingerBill
7bd6d16d76 Merge pull request #7438 from kalsprite/asm_doc_category
Give asm templates a documentation category instead of a blank header and a null `%s`
2026-08-26 08:41:20 +01:00
gingerBill
85b9dcb4b8 Merge pull request #7461 from kalsprite/fmt_left_align_space_pad
fill left-justified field with spaces
2026-08-26 08:41:00 +01:00
kalsprite
7d7d9a01ee fill left-justified field with spaces 2026-08-25 23:55:55 -07:00
kalsprite
c3bc5b69ac Merge branch 'master' into asm_doc_category 2026-08-25 23:08:48 -07:00
kalsprite
c1aeb47ce5 swizzle target multi-assignment 2026-08-25 22:22:33 -07:00
kalsprite
ae549bf34b broadcast a constant into every array level 2026-08-25 21:47:02 -07:00
mo
2d1253e3e6 add regression test for #7336
Closes #7336.
Fixed by #7327.
2026-08-26 15:08:01 +12:00
gingerBill
2214d90997 Merge branch 'master' into bool_comparison_normalise 2026-08-25 15:31:19 +01:00
gingerBill
771cbfa31a Merge pull request #7439 from ssenthilnathan3/fix/proc-literal-type-canonicalization
Fix canonical names for types in procedure literals
2026-08-25 15:12:32 +01:00
Senthilnathan
559ed487e6 fix: canonical names for types in procedure literals 2026-08-25 14:41:48 +05:30
Jeroen van Rijn
5a994d4ea2 Merge pull request #7450 from kalsprite/mod_min_neg_one
Fix: `min(T) % -1` kills the process with SIGFPE, at every hardware width.
2026-08-25 01:32:21 -07:00
kalsprite
5628815bfe mod -1 2026-08-24 19:46:47 -07:00
Jeroen van Rijn
33d4c68abe Merge pull request #7401 from kalsprite/nbio_windows_wakeup
nbio(windows): fix use-after-free, spurious poll readiness, and double completion
2026-08-24 19:02:24 -07:00
kalsprite
4ecaa7dfd9 normalize bool cmp 2026-08-24 18:34:59 -07:00
Jeroen van Rijn
66f9dbca8a Merge branch 'master' into bool_be_conversion 2026-08-24 18:31:30 -07:00
kalsprite
c3bfbea235 big endian bool cmp 2026-08-24 18:15:01 -07:00
kalsprite
301baf0b88 remove faulty tests 2026-08-24 17:46:55 -07:00
gingerBill
805fc07854 Fix indentation of run.sh 2026-08-24 14:13:28 +01:00
gingerBill
cebceb9bb2 Merge branch 'master' into asm_rip_width 2026-08-24 09:31:54 +01:00
gingerBill
48daf8e511 Merge pull request #7431 from kalsprite/asm_named_register_slot
Reject asm operands in slots only a named hardware register can fill
2026-08-24 09:30:20 +01:00
gingerBill
754ac9a45b Merge pull request #7437 from kalsprite/asm_cast_guard
Asm cast guard
2026-08-24 09:25:13 +01:00
kalsprite
b875baea08 asm template doc category 2026-08-24 00:55:16 -07:00
kalsprite
40fd892cf5 Reject a named asm template used as a value instead of aborting the compiler 2026-08-24 00:27:26 -07:00
kalsprite
b6c64c28b5 Diagnose in an asm template instead of aborting with SIGILL 2026-08-23 22:36:57 -07:00
kalsprite
deb45f3e6a asm named slots 2026-08-23 21:34:31 -07:00
Jeroen van Rijn
24d86de624 One more. 2026-08-23 21:49:39 +02:00
Jeroen van Rijn
2439aaf181 Remove imports of deprecated core:os/old. 2026-08-23 21:46:30 +02:00
gingerBill
fff69510b9 Merge pull request #7412 from mocompute/fix-7008
fix incorrect offset_of and size_of for unions with cyclic pointers
2026-08-23 10:52:14 +01:00
Manuel
d79ef965a0 Fix formatting 2026-08-22 21:50:07 +02:00
Manuel
ee04c3b272 Add murmur3 implementation 2026-08-22 15:48:38 +02:00
Jeroen van Rijn
2370de888c Merge branch 'master' into type_call_null_arg 2026-08-22 03:12:01 +02:00
Jeroen van Rijn
830f41e280 Merge pull request #7417 from kalsprite/foreign_sig_named_struct
Fix segfault comparing two foreign declarations of the same symbol
2026-08-22 03:11:27 +02:00
kalsprite
c29596e88f fix test typo 2026-08-21 17:59:02 -07:00
kalsprite
ef1c5fe675 Fix compiler segfault on a bare in a type position call 2026-08-21 17:54:13 -07:00
kalsprite
f8bdfa0857 Fix segfault comparing two foreign declarations of the same symbol 2026-08-21 17:31:42 -07:00
kalsprite
7fe49fbffb Fix compiler panic on a selector into 2026-08-21 16:38:56 -07:00
mo
7bb0bc353f add regression test for incorrect offset_of 2026-08-22 11:12:11 +12:00
kalsprite
fe52f23b50 tests/core/nbio/remove.odin 2026-08-21 15:25:18 -07:00
kalsprite
d29b2cadbd nbio(tests): fill the socket until sending blocks 2026-08-21 21:58:40 -07:00