; example that does not allocate enough memory for an array ; this will generate an error when accessing some elements ; of the array global main extern malloc extern atoi ;========================= ; DATA ;======================== section .data ; read from command line argument, size of the array tab size: dd 0 ; int *tab which will be allocated dynamically tab: dd 0 ;========================= ; CODE ;======================== section .text ; int main(int argc, char *argv[]) main: push ebp mov ebp, esp pushad ; get size of tab ; size = atoi(argv[1]); mov ebx, [ebp + 12] push dword [ebx + 4] call atoi add esp, 4 mov [size], eax ; we make a mistake here !!!!!!!!!!!!!!!!!!!!!!!! ; we write : ; tab = (int *) malloc(size) ; instead of : ; tab = (int *) malloc(size * sizeof(int)) push eax call malloc add esp, 4 mov [tab], eax ; for (int i=0; i