私はvalgrindを使用していますが、何らかの理由で、Cで同じサイズの2つの文字列を含む単純な文字列コピーを使用するとメモリエラーが発生し続けます。
影響を受けるコードは次のとおりです。
node->entry = (char*)malloc(strlen(string)*sizeof(char));
strcpy(node->entry, string);
文字列は次のとおりです。char*string="HelloThere"。エラーは次のとおりです。サイズ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)
助けてくれてありがとう!