When I am trying to execute my program Its getting error like this -
sendip: malloc.c:4631: _int_malloc: Assertion `(unsigned long)(size)
>= (unsigned long)(nb)' failed
Tried capturing error through valgrind,got this one -
HEAP SUMMARY:
==3335== in use at exit: 24 bytes in 2 blocks
==3335== total heap usage: 111 allocs, 109 frees, 7,929 bytes allocated
==3335==
==3335== 4 bytes in 1 blocks are definitely lost in loss record 1 of 2
==3335== at 0x40268A4: malloc (vg_replace_malloc.c:236)
==3335== by 0x8049EEF: main (sendip.c:435)
==3335==
==3335== 20 bytes in 1 blocks are definitely lost in loss record 2 of 2
==3335== at 0x40268A4: malloc (vg_replace_malloc.c:236)
==3335== by 0x4031F57: ???
==3335== by 0x804A338: main (sendip.c:521)
==3335==
Line no. 435
datalen = stringargument(gnuoptarg, &datarg);
/*This is the line*/ data=(char *)malloc(datalen);
memcpy(data, datarg, datalen);
If needed I could add other pieces of code ... but help me getting out of this ??? What is this I am getting no clue ..
Information that is required by the Web page but omitted by the user. Information that is provided by the user but that falls outside the required data format or values.
Providing the ability to reverse actions allows users to correct a mistake that could result in serious consequences. Providing the ability to review and correct information gives the user an opportunity to detect a mistake before taking an action that has serious consequences.
You must be overwriting "data" and forgetting to free the old content... have you checked this?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With