我正在编写一个套接字程序来下载图像.问题是,当我在像gif这样的小图片上测试我的代码时,它运行正常.但是当我使用JPG图片(大于GIF)运行它时,我收到了错误消息:
*** glibc detected *** /home/ubuntu/NetBeansProjects/myDownloader/dist/Debug/GNU-Linux-x86/mydownloader: free(): invalid next size (normal): 0x0a03c978 ***
Run Code Online (Sandbox Code Playgroud)
请查看代码,我将提供有关错误的更多信息.
FILE* pFile;
long lSize;
unsigned char* buffer;
size_t result;
FILE* combinedFile = fopen("mypic.jpg", "wb+");
for(i = 1; i <= numberOfPartitions; i++)
{
sprintf(filename, "part%d", i);
pFile = fopen(filename, "rb");
//obtain file size
fseek(pFile , 0 , SEEK_END);
lSize = ftell(pFile);
rewind(pFile);
// allocate memory to contain the whole file:
buffer = (unsigned char*) malloc(sizeof(unsigned char) * (lSize + 1));
if(buffer == NULL)
{
fputs("Memory error", stderr); …Run Code Online (Sandbox Code Playgroud) 我为冗长的代码道歉.我有一个简单的问题,但我认为我包含了我的代码,所以我很清楚我来自哪里.我得到了realloc腐败.我认为腐败是因为我没有正确解放.实际上,我不确定glibc甚至说什么或意味着什么.任何人都能简单地向我解释一下吗?再次抱歉冗长的代码.
#include "draw2.h"
#include "draw2a.h"
#include "draw2b.h"
const char Exec_c[] = "java -jar Sketchpad.jar";
void parseFile(FILE * fp, FILE *sketcher){
char line [MAX_WORD] = {"NULL"};
char word [MAX_WORD] = {"NULL"};
char figureName [MAX_WORD] = {"NULL"};
struct figure *pointsAndname;
long int countNumberoffigures = 0;
printOutput();
long int temp = 10;
pointsAndname = malloc(temp * sizeof(struct figure));
assert(pointsAndname != NULL);
while ( fgets(line, MAX_WORD - 1, fp) != NULL ){
int nuRead = sscanf(line, "%s", word);
assert(pointsAndname != NULL);
if ( nuRead …Run Code Online (Sandbox Code Playgroud) 可能重复:
C++错误:free():下一个大小无效(快):
这是一个C++问题(虽然是'C++被滥用'的问题).备选副本:面临错误:glibc检测到免费无效下一个大小(快)
我正在使用Linux工具生成一些n/w流量,但是当我尝试发送大于某个长度的数据时,当工具为其提供时,会出现此错误.
我的整个项目都介于两者之间.由于我没有创建该工具,因此不确定错误发生在哪里......并且此错误(偶数gdb)没有给出关于问题所在位置的任何提示.如何检测错误点?
如果有问题,我会给出一些问题的快照.请指导我该怎么办?它对我来说看起来像一个网格.
udit@udit-Dabba ~ $ sendip -v -p ipv6 -f file.txt -6s ::1 -p esp -es 0x20 -eq 0x40 -ei
abcd -eI zxc -p tcp -ts 21 -td 21 ::2 | more
*** glibc detected *** sendip: free(): invalid next size (normal): 0x09da25e8 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x6b961)[0x17b961]
/lib/i386-linux-gnu/libc.so.6(+0x6d28b)[0x17d28b]
/lib/i386-linux-gnu/libc.so.6(cfree+0x6d)[0x18041d]
/lib/i386-linux-gnu/libc.so.6(fclose+0x14a)[0x16b9ca]
/lib/i386-linux-gnu/libc.so.6(+0xe053f)[0x1f053f]
/lib/i386-linux-gnu/libc.so.6(__res_ninit+0x25)[0x1f0815]
/lib/i386-linux-gnu/libc.so.6(__res_maybe_init+0x130)[0x1f1810]
/lib/i386-linux-gnu/libc.so.6(__nss_hostname_digits_dots+0x34)[0x1f37d4]
/lib/i386-linux-gnu/libc.so.6(gethostbyname2+0x96)[0x1f82f6]
/usr/local/lib/sendip/ipv6.so(set_addr+0x2d)[0x3eec69]
sendip(main+0x8eb)[0x804a635]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x126e37]
sendip[0x8048f81]
======= Memory map: ========
00110000-0026a000 r-xp 00000000 08:07 3408705 /lib/i386-linux-gnu/libc-2.13.so
0026a000-0026b000 ---p 0015a000 …Run Code Online (Sandbox Code Playgroud)