[sr-dev] Does shm_free() make the pointer NULL?

Iñaki Baz Castillo ibc at aliax.net
Tue Feb 28 20:14:22 CET 2012


Hi, I'm realizing that a doble freeing occurs in regex module when it
fails to start due to module params errors. But I'm sure it didn't
occur in Kamailio 1.5. My question is the following:


  static int *number;
  number = shm_malloc(sizeof(int));
  shm_free(number);

Should now number be NULL? I confirm that it's NOT, so I get a double
freeing since the function free_shared_memory() is executed twice and
I check "if (number)" before doing "shm_free(number)".

So is it a change in 3.X? should I write:

  shm_free(number);
  number = NULL;

?

Thanks a lot.

-- 
Iñaki Baz Castillo
<ibc at aliax.net>



More information about the sr-dev mailing list