Commit Graph

8232 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
54b680a167 Merge pull request #7480 from FourteenBrush/patch-8
`core:net`: use explicitly passed allocators
2026-08-29 13:49:04 -07:00
FourteenBrush
a635f0ef91 net.split_url: fix length on query values 2026-08-29 22:39:15 +02:00
FourteenBrush
57181d5c27 Avoid allocations in net.split_url 2026-08-29 21:54:26 +02:00
thetarnav
db2f88cff9 Improve parsing field docs and comments (fixes #5353) 2026-08-29 19:22:18 +02:00
FourteenBrush
af6bcc13d6 net.parse_record: use explicitly passed allocator 2026-08-29 18:56:08 +02:00
FourteenBrush
7198bf5d80 net.split_url: use explicitly passed allocator 2026-08-29 18:27:07 +02:00
Laytan Laats
3fb6d8965b [core:os] add device to File_Info 2026-08-26 20:44:01 +02:00
Laytan
897c99a9a3 [core:debug/trace] remove os, fmt, slice, and strconv imports (#7408)
* [core:debug/trace] remove `os`, `fmt`, `slice`, and `strconv` imports

* [core:debug/trace]: print memory nicely

A bit of a modified, minimal core:fmt `%m` (to not need `core:strconv`)
2026-08-26 20:19:38 +02: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
6a83f08c8b Fix justified printing of 0 producing all spaces. 2026-08-26 12:11:38 +02:00
gingerBill
cef4fb01a4 Merge pull request #7424 from samuelgozi/foundation-cocoa-ios
core:sys/darwin/Foundation: Skip Cocoa import on iOS
2026-08-26 08:43:35 +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
deeddc7b33 add missing endian 128 types 2026-08-25 23:03:11 -07:00
mo
750aecb6de win test runner: ignore informational exceptions
and accept BREAK and CLOSE as synonyms for CTRL_C
2026-08-26 10:12:13 +12:00
Thomas Skarshaug
9e1e7d60c9 Fix simple typo in process.odin 2026-08-25 21:49:11 +02:00
gingerBill
f7f3d3f198 asm: reenable riscv64 2026-08-25 19:30:38 +01:00
gingerBill
65c927841a Merge branch 'master' into bill/asm-cfg 2026-08-25 15:04:39 +01:00
Coranath
3da4bb91cd Fixed type in math/rand.odin
Fixed typo on line 564, from "inclusice" to "inclusive"
2026-08-24 22:46:30 -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
gingerBill
032566714c asm: correctly handle flags in the CFG 2026-08-24 22:56:49 +01:00
gingerBill
322f59dae0 Implement a CFG for the assembler to improve the soundness of the checks 2026-08-24 21:49:32 +01:00
gingerBill
9ae9a9bf99 asm: Add support for constraint checks such as division by zero or overshifting 2026-08-24 18:18:28 +01:00
gingerBill
2f588e0329 Correct clobbering for instructions which did not write actually write to memory 2026-08-24 12:20:45 +01:00
gingerBill
39afdfc609 Begin work on improving #pure error handling 2026-08-24 12:13:24 +01:00
gingerBill
c3c3aa1533 Add #pure directive for asm templates 2026-08-24 11:46:07 +01:00
gingerBill
34e7a3bb58 Update binary tables 2026-08-24 11:02:06 +01:00
gingerBill
c41c0fb376 Add non-deterministic flags to x86 2026-08-24 11:01:22 +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
kalsprite
deb45f3e6a asm named slots 2026-08-23 21:34:31 -07:00
Jeroen van Rijn
ce379d033a Deprecate core:os/old as advertised. 2026-08-23 21:42:58 +02:00
Samuel Elgozi
2f68a64614 core:sys/darwin/Foundation: Skip Cocoa import on iOS 2026-08-23 20:14:57 +03: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
kalsprite
7bb55ba45b nbio(windows): poll sockets through AFD 2026-08-21 21:31:49 -07:00
kalsprite
d2da33235d nbio(windows): handle queued work in the tick that was woken for it; nbio(tests): let wake_up tolerate a tick that returns without progress 2026-08-21 09:18:57 -07:00
gingerBill
f2d9b10fdc Merge pull request #7406 from odin-lang/bill/rexcode-riscv-clobber
Inline `asm` RISC-V Support
2026-08-21 17:25:30 +02:00
gingerBill
648c418fc4 Restrict riscv to only allow [base + disp] (i.e. disallow index*scale style things) 2026-08-21 14:31:58 +01:00
gingerBill
4a4a5045f8 Check for float register width exactly for risc-v frontend 2026-08-21 12:19:02 +01:00
gingerBill
a604ddceb1 Support pseudo macro mnemonics (for RISC-V) in the frontend 2026-08-21 11:47:41 +01:00
kalsprite
6e690afaf1 revert wake change 2026-08-21 00:09:43 -07:00
kalsprite
bcf2dcd2f0 nbio(windows): don't complete synchronously-failed overlapped ops twice 2026-08-20 23:39:21 -07:00
kalsprite
ae56bf5456 nbio(windows): clear the OVERLAPPED when arming a poll; nbio(windows): tear down poll waits before their event; nbio(windows): clear the socket event record on poll completion 2026-08-20 23:04:26 -07:00
kalsprite
2719a089ec recompute timeouts 2026-08-20 20:43:08 -07:00
Carlyle
89447378ea fixed negative read bug in core:image/jpeg 2026-08-20 19:49:32 -07:00
gingerBill
d0fb380c20 Support riscv _aq _rl _aqrl suffixes for mnemonics 2026-08-21 01:05:47 +01:00
gingerBill
de8c0dc4fe Fix register width test for risc-v, and improve operand slot type inference for risc-v 2026-08-21 00:38:34 +01:00
gingerBill
7a7bfea0bd Begin work on pseudo mnemonics in the checker 2026-08-20 19:12:44 +01:00