We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 88f0d46 commit 06f179dCopy full SHA for 06f179d
1 file changed
common/lib/uri.c
@@ -497,6 +497,16 @@ grew:;
497
buf_len += got;
498
}
499
500
+ // Release the page-aligned tail past the actual data so we don't
501
+ // hand the OS up to 64 MiB of slack typed as `type`. Keep at least
502
+ // one page so the returned handle has a valid address.
503
+ uint64_t kept = ALIGN_UP(buf_len, 4096, panic(true, "uri: alignment overflow"));
504
+ if (kept == 0) kept = 4096;
505
+ if (kept < buf_cap) {
506
+ uri_release_range(buf_addr + kept, buf_cap - kept);
507
+ buf_cap = kept;
508
+ }
509
+
510
#if defined (__i386__)
511
if (pool != NULL) pmm_free(pool, 0x100000);
512
#endif
0 commit comments