blob: ed92eb9768ff891ab7645d9462295ee28269dced (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include <stdlib.h>
#include <time.h>
#include <dlfcn.h>
#include <stdio.h>
typedef void *(*malloc_t)(size_t size);
static malloc_t real_malloc;
extern void *malloc (size_t size) {
if (!real_malloc)
real_malloc = dlsym (RTLD_NEXT, "malloc");
if (!real_malloc)
return NULL; // lmao
srand (time (NULL));
int val = (rand () % 2)+1;
if (val > 1) {
long loss = (rand () % (int) size)+5;
return real_malloc (size - loss);
} else {
return real_malloc (size);
}
}
|