tags:

views:

87

answers:

1
in big while statement
 if(tempc=='j')  //i am creating array if before is not freeing
  {              //if it filled with data  just add another data in it
    current=atoi(tutar[i+1])-1;

      if(arrays[current]==NULL)//?? can should i do arrays[]==EOF or what
   {    arrays[current]=malloc(sizeof(int)*4);
   l_arrays[current]=calloc(2,sizeof(int));
   c_arrays[current]=calloc(2,sizzeof(int)); 
   }
   else
     {
   a=*l_arrays[current]; j=*l_arrays[current];
   }
  i=i+2;
  continue;
  }
  if(tempc=='d')     //i am freeing the array[x] 
  {
  command=atoi(tutar[i+1])-1;
  free(arrays[command]);
  free(l_arrays[command]);  free(c_arrays[command]);
  i=i+2;
  continue; 
  }

 if after the fill data , i send d char and i have freed that pointer
 and then if somehow user want to use that pointer again ,i can give pointer if it is
 freeing area if not i cannot give 
+3  A: 

You're freeing a pointer that points to a string literal. That is a big error.

You're also checking the pointer p against the integer -1 which, if not a big error, is at least a big red flag. We'd need to see the rest of the code to be sure.

Thomas