what does this error suggest?

20,223

You must be overwriting "data" and forgetting to free the old content... have you checked this?

Share:
20,223
Udit Gupta
Author by

Udit Gupta

Hello All !!! About me , I am a developer. Here Because I think mutual colloboration is the best way to learn and develope best applications.

Updated on July 09, 2022

Comments

  • Udit Gupta
    Udit Gupta almost 2 years

    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 ..