I have a problem when doing a malloc inside this code,
  /*function starts*/
   if(NULL==(partial_results=(bignum_t**)malloc(sizeof(bignum_t*)*long_op2))){
        return NULL;
    }       
    /*to initialize all the members of the array*/
    for(i=0;i<long_op2;i++){
        (*(partial_results+i))=NULL;
    }
    for(i=long_op2-1;i>=0;i--){
        digit2=op2->digits[i]-48;
        count++;
        carry=0;
        if(count==1){
            count2=0;
        }else{
            count2=count-1;
        }
        /*the next malloc is the one that fails*/
        if(NULL==(*(partial_results+(count-1))=(bignum_t*)malloc(sizeof(bignum_t)))){
            return NULL;
        }   
        /*after this the codes continues, but everything from here is ok an it isn't causing any problem*/
The thing here is, I'm trying to create an array of long_op2 elements (which is 9), so in the first malloc I create a 9 bignum_t pointers array. Then, inside the for, I try to create a bignum_t structure for each member of the array. When long_op2 is less or equal to 6 I have no problem, but when it's 7 or more, the first malloc, (the one that's suppose to create the pointers) doesn't work. I'm getting the error,
tp3: malloc.c:2372: sysmalloc: Assertion (old_top == (((mbinptr)      (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 *(sizeof(size_t))) - 1)) & ~((2 *(sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long) old_end & pagemask) == 0)' failed.
Aborted (core dumped)
The thing is, I'm not trying to write more than the quantity of the array created, because count gets to 8 max if long_op2 is 9, so that's ok. Another thing that's quite weird, is that when I run the program using Valgrind, it does work!
PD: It's my first question in here, so if I made any mistakes I apologize.
PD2: Here's how the program is working.
980581618*215129902
long_op1 & long_op2     9   9
for with: i, count-1    8   0
doing malloc malloc done 
for with: i, count-1    7   1
doing malloc malloc done 
for with: i, count-1    6   2
doing malloc malloc done 
for with: i, count-1    5   3
doing malloc malloc done 
for with: i, count-1    4   4
doing malloc malloc done 
for with: i, count-1    3   5
doing malloc malloc done 
for with: i, count-1    2   6
doing malloc malloc done 
for with: i, count-1    1   7
doing malloc malloc done 
for with: i, count-1    0   8
doing malloc 
tp3: malloc.c:2372: sysmalloc: Assertion ...
 
     
    