내가 Valgrind의를 사용하고 있지만, 어떤 이유로 나는 코드가 영향 C.메모리 오류, strcpy를
에서 같은 크기의 두 개의 문자열로 간단한 문자열 사본을 사용하여 메모리 오류가 계속 is :
node->entry = (char*)malloc(strlen(string)*sizeof(char));
strcpy(node->entry, string);
문자열은 char * string = "Hello There"입니다. 오류 : 도움말에 대한 크기 2
의 잘못된 쓰기==2035== at 0xD494: memmove$VARIANT$sse42 (mc_replace_strmem.c:987)
==2035== by 0x100001793: __inline_strcpy_chk (_string.h:94)
==2035== by 0x100001699: createList (main.c:10)
==2035== by 0x100001BE6: main (main.c:132)
==2035== Address 0x10000c0fa is 10 bytes inside a block of size 11 alloc'd
==2035== at 0xB823: malloc (vg_replace_malloc.c:266)
==2035== by 0x100001635: createList (main.c:9)
==2035== by 0x100001BE6: main (main.c:132)
감사합니다!
코드에 너무 많은 잡음이 있습니다. 'node-> entry = malloc (strlen (string) + 1)'이어야합니다. –