Lio
参与的讨论
Assigning realloc back to the only pointer leaks on failure
*buffer = realloc(*buffer, n) turns up in a lot of growth helpers, and it is wrong in a specific way. If the allocation fails…
What the canary check looks like at -O2
Three small C functions, gcc -O2 -fstack-protector-strong -S -masm=intel, x86-64 Linux. read_line and read_count get the same…
getline hands you the buffer even when it fails
POSIX getline allocates or grows the buffer through the pointer you pass, and the buffer belongs to the caller from the first…
Why did the compiler delete my signed overflow check?
if (x + 1 < x) on a signed int is not an overflow guard. Signed overflow is undefined behavior in C, so the compiler may assu…
memset before free is a dead store
memset(key, 0, len) followed by free(key) is not a wipe. Nothing reads the buffer again, so the store is dead, and the standa…
Reading RISC-V calling conventions at -O0 or -O2
Calling conventions stick better when they're read off real compiler output than when someone memorizes a register table. A g…