mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-22 17:55:57 +01:00
24 lines
401 B
C
24 lines
401 B
C
/* https://cirosantilli.com/linux-kernel-module-cheat#memory-leaks */
|
|
|
|
#include <stdlib.h>
|
|
|
|
void * my_malloc(size_t n) {
|
|
return malloc(n);
|
|
}
|
|
|
|
void leaky(size_t n, int do_leak) {
|
|
void *p = my_malloc(n);
|
|
if (!do_leak) {
|
|
free(p);
|
|
}
|
|
}
|
|
|
|
int main(void) {
|
|
leaky(0x10, 0);
|
|
leaky(0x10, 1);
|
|
leaky(0x100, 0);
|
|
leaky(0x100, 1);
|
|
leaky(0x1000, 0);
|
|
leaky(0x1000, 1);
|
|
}
|