我有一个这样的指针:
const u_char *packet;
从42个元素到某个点,我必须将它复制到另一个char指针中。
u_char *payload = new u_char[];
int j = 0, l = 0;
while (j < header->caplen - 42 - 1) {
if (j >= 42){
payload[l] = packet[j];
l++;
}
j++;
}
payload[l] = '\0';它工作得很好,但在某个特定的数据包中,它给出了这个错误:
Unhandled exception at 0x55B3FB53 (msvcr120d.dll) in eval_waic.exe: 0xC0000005: Access violation reading location 0xCCCCCCCC知道为什么吗?它工作得很好,直到那个包!我检查过了,这不是数据包的问题..
发布于 2014-08-04 18:03:31
您需要为payload提供足够的空间来存储结果。据我所见
u_char *payload = new u_char[header->caplen - 42];应该能行得通。
https://stackoverflow.com/questions/25115714
复制相似问题