Hi, 

I want to do the following however not sure what the correct way to do 
would be.  I'd be grateful if you can give suggestions.  

Basically I'd like to trace the usage of a variable v.   For instance in 
the code below  I'd like to check for usage of a ptr after it has been 
freed.   So the variable (or ptr) of interest is myptr , and statement   
printf("myptr1 %d\n",*myptr);   is what I am interested in , since it 
uses myptr after myptr is freed. 

I am wondering if I need to calculate a CFG for the code ?   or what 
would the common strategies be for these purposes ?   Some pseudo code 
would be helpful.  


Thanks in advance


// example  

void f1(int *myptr1){

  free(myptr1);
  myptr1 = ((void *)0);
 
}

int main(int argc, char *argv[]){
  int *myptr  = (int *)malloc(sizeof(int));
  *myptr1 = 10;

  printf("myptr1 %d\n",*myptr);   //OK  , no prob

  f1(myptr);   //free ptr

  printf("myptr1 %d\n",*myptr);   //NOT-OK,  deref a nullptr

  return 0;
}


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to