We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Use-after-free

From Esolang
Jump to navigation Jump to search
Use-after-free
Designed by User:RaiseAfloppaFan3925
Appeared in Category:2026
Computational class Below combinational logic?
Reference implementation Unimplemented
Influenced by Malloc, Double free, Mixed allocators

Use-after-free is an esoteric programming language by User:RaiseAfloppaFan3925 in 2026 based on the undefined behavior of using a pointer after freeing it in C. It can be considered a superset of Malloc.

Double free is used as the base for the syntax and semantics of Use-after-free. If you haven't understood Double free then you likely won't be able to understand Use-after-free.

Functions

There are malloc and free.

printf exists too and is just C's printf.

The peek function reads a single byte from memory.

?! message
message : "Hello, world!"
printf "peek message = %c\n" peek message

Output:

peek message = H

The poke function overrides a single byte in memory.

?! ptr
ptr : malloc sizeof(char)
poke ptr 123
printf "%d\n" ` ptr
poke ptr -98
printf "%d\n" ` ptr

Output:

123
-98

There are also variants of both peek and poke for different types in C. However, for peek, only the integer type ones are actually useful for computation as everything else would raise a type error if you tried to assign them to a variable since non-integer types cannot be casted into void* and the only usable variable type is void* as denoted by ?!.

Peek Poke C type
peek and peekuc poke and pokeuc char and unsigned char
peeks and peekus pokes and pokeus short and unsigned short
peeki and peeku pokei and pokeu int and unsigned int
peekl and peekul pokel and pokeul long and unsigned long
peekll and peekull pokell and pokeull long long and unsigned long long
peekf pokef float
peekd poked double
peekld pokeld long double
peekp pokep void*

Examples

"Hello, world!" program

printf "Hello, world!\n"

XKCD Random Number

?! comment
comment : "Chosen by fair dice roll."
printf "4\n"

Use-after-free error

?! value
value : malloc sizeof(int)
pokei value ` 8
free value
printf "%d\n" ` value

Something very bad that you should not do

?! tmp
free free
free (poke (malloc 10))
free "Hello, world!\n"
free printf
tmp : malloc
malloc : "a"
free malloc
malloc : tmp
free malloc

See also