[OpenSIPS-Users] Bug in modules/db_postgres/res.c

Alexander goal81 at gmail.com
Sun Dec 20 21:08:49 CET 2009


  Hello,

  I've  found  a bug in db_postgres module. In res.c file, near line 291, we can
see:

  for (col = 0; col < RES_COL_N(_r); col++) {
       switch (RES_TYPES(_r)[col]) {
           case DB_STRING:
           case DB_STR:
               break;
           default:
               LM_DBG("freeing row_buf[%d] at %p\n", col, row_buf[col]);
               pkg_free(row_buf[col]);
       }

  pkg_free() is called wrong, it should be like this:

  if (row_buf[col]) pkg_free(row_buf[col])

  Without  this  'if',  OpenSIPS produces "WARNING:core:fm_free: free(0) called"
and sometimes even crashes.




More information about the Users mailing list