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.
Double free
- Not to be confused with the memory management bug..
| Designed by | User:RaiseAfloppaFan3925 |
|---|---|
| Appeared in | 2026 |
| Computational class | Below combinational logic |
| Reference implementation | Unimplemented |
| Influenced by | Malloc |
Double free is a programming language by User:RaiseAfloppaFan3925 inspired by and is a superset[1] of Malloc. It is obviously based on the memory management bug. Here, you can only do two things: allocate memory, and free a pointer twice.
Syntax and semantics
Double free has the malloc command from Malloc, but it has an extension:
varname malloc x
This points the varname to the x bytes of memory allocated.
Additionally, allocating a negative amount of bytes will just wrap around, as you are trying to use a two's complement signed number in a function that expects an unsigned integer. Specifically, the argument to malloc is a size_t as defined by the C standard. So, the following program will just allocate an insane amount of memory.
malloc -1
Since size_t's size is platform-dependent, the amount of bytes this allocates is also varying.
Variables are implicitly defined as garbage values before the program starts, just to make the language more beginner-friendly.
Variables can then be used in the doublefree command as follows:
doublefree varname
This just frees the variable twice.
Since malloc(0) is implementation-defined in the C standard, it is also implementation-defined in Double free.
Examples
Allocate 5 bytes of memory and double-free it
x malloc 5 doublefree x
Allocate a gibibyte of memory and double-free it
ptr malloc 1099511627776 doublefree ptr
Leak 8 bytes and double-free 8 bytes
ptr1 malloc 8 ptr2 malloc 8 doublefree ptr1
Test memory security
x malloc 1024 doublefree x x malloc 1024 doublefree x x malloc 1024 doublefree x x malloc 1024 doublefree x
I have no idea
doublefree a doublefree b doublefree c
This thing
ptr malloc -1
With a 16-bit size_t, this will allocate 65,536 bytes. With 32-bit size_ts, this will allocate 4 GiB. With 64-bit size_ts, this will allocate 18 quintillion bytes.
Wild card program
ptr malloc 0 doublefree ptr
See also
Notes
- ↑ As of 12 August 2026 9:52 AM Philippine Standard Time, Malloc has no defined behavior on what happens outside of just allocating N bytes for a
malloc Ncommand. This means that Double free can define behavior outside of those boundaries (for example, when you allocate a negative amount of bytes) and still remain a superset.