Bonjour,
Je m'arrache les cheveux depuis plusieurs heures car je ne parvien pas à résoudre mon problème :
Voici la sortie de mon programme :
Je pense que l'erreur vien de ce code la :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 *** glibc detected *** ./irawk: realloc(): invalid next size: 0x0804b0a8 *** ======= Backtrace: ========= /lib/tls/i686/cmov/libc.so.6[0xb7e5d3aa] /lib/tls/i686/cmov/libc.so.6(__libc_realloc+0xff)[0xb7e5dcdf] ./irawk[0x80487cd] ./irawk[0x8048d2a] ./irawk[0x8048fab] /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xdc)[0xb7e0a8cc] ./irawk[0x8048591]
Est-ce que vous voyez une erreur?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 for (str = instruction, count = 0 ; ; str = NULL) { token = strtok_r(str, "\"", &saveptr); if (token == NULL) break; printf("token : %s\n", token); instruction_tab = (char **)realloc(instruction_tab, (sizeof(char*))); if(instruction_tab == NULL){ printf("erreur d'allocation mémoire\n"); return NULL; } instruction_tab[count] = (char*)malloc(sizeof(token)); if(instruction_tab[count] == NULL){ printf("erreur d'allocation mémoire\n"); for(i = 0; i < count ; i++){ free(instruction_tab[i]); } free(instruction_tab); free (instruction); return NULL; } strcpy(instruction_tab[count], token); count ++; }
Une idée ?![]()
Partager