salut,
j'utilise valgrind pour vérifer les fuites de mémoire et je ne comprend pas pourquoi, il me renvoit ces erreurs :
j'ai pu lire "This message says that the program did an illegal 4-byte read of address 0xBFFFF74C ...." dans la documentation de valgrind mais tout ça ne m'aide pas trop...
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
25
26
27
28
29
30
31 ==2025== Invalid read of size 4 ==2025== at 0x8048587: free_gettok (test.c:35) ==2025== by 0x80485EB: main (test.c:48) ==2025== by 0x4025890B: __libc_start_main (in /lib/libc-2.3.2.so) ==2025== by 0x80483A0: (within /home/bloops/a.out) ==2025== Address 0x41094514 is 0 bytes after a block of size 32 alloc'd ==2025== at 0x4002A079: realloc (in /usr/lib/valgrind/vgskin_memcheck.so) ==2025== by 0x80484E3: gettoken (test.c:19) ==2025== by 0x80485DD: main (test.c:47) ==2025== by 0x4025890B: __libc_start_main (in /lib/libc-2.3.2.so) ==2025== ==2025== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) ==2025== ==2025== 1 errors in context 1 of 1: ==2025== Invalid read of size 4 ==2025== at 0x8048587: free_gettok (test.c:35) ==2025== by 0x80485EB: main (test.c:48) ==2025== by 0x4025890B: __libc_start_main (in /lib/libc-2.3.2.so) ==2025== by 0x80483A0: (within /home/bloops/a.out) ==2025== Address 0x41094514 is 0 bytes after a block of size 32 alloc'd ==2025== at 0x4002A079: realloc (in /usr/lib/valgrind/vgskin_memcheck.so) ==2025== by 0x80484E3: gettoken (test.c:19) ==2025== by 0x80485DD: main (test.c:47) ==2025== by 0x4025890B: __libc_start_main (in /lib/libc-2.3.2.so) ==2025== IN SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) ==2025== ==2025== malloc/free: in use at exit: 0 bytes in 0 blocks. ==2025== malloc/free: 16 allocs, 16 frees, 656 bytes allocated. ==2025== ==2025== No malloc'd blocks -- no leaks are possible.
les lignes de codes concernées (je sais pas si je peux me permettre de coller le code en entier ?) :
ligne 35 : p=(char **)realloc(p, (j+1) * sizeof(char *));
ligne 19 : while(ptr[i]) // ptr => char **ptr;
bon voilà, je sais pas si c'est très clair mon histoire mais si quelqu'un a une idée... merci d'avance
post C redirigé sur ce forum par HRS
Partager