Branch: Tag:

2016-02-17

2016-02-17 18:55:13 by Stephen R. van den Berg <srb@cuci.nl>

pgsql: Protect against execution in destructed objects.

612:    plugbuffer->add_int8(0);    PD("%O\n",(string)plugbuffer);    if(catch(ci->start()->add_hstring(plugbuffer,4,4)->sendcmd(SENDOUT))) { - #ifdef PG_DEBUG -  if(!_options) -  PD("_options is zero, %O\n",this); - #endif -  if(_options && _options.reconnect) // FIXME why can _options be 0? +  if(this) // Only when not destructed yet +  if(_options.reconnect)    _connectfail();    else    destruct(waitforauthready); -  } else // Do not flush at this point, PostgreSQL 9.4 disapproves +  return; +  } +  } // Do not flush at this point, PostgreSQL 9.4 disapproves    procmessage();   } - } +       private void procmessage() {    int terminating=0;
1174:    break;    }    PD("Closing database processloop %O\n",err); +  if(this)    _delayederror=err;    for(;objectp(portal);portal=qportals->read())    if(objectp(portal)) {
1184:    }    if(!ci->close() && !terminating && _options.reconnect)    _connectfail(); -  else +  else if(this)    destruct(waitforauthready); -  if(err && !stringp(err)) +  if(this && err && !stringp(err))    throw(err);   }