Is there a bug?

xuzhen xuzhen____ercist.iscas.ac.cn
Fri Aug 25 13:43:49 CEST 2000


hi,
I used the method get_rows() of MibTable, but found it won't work. So I
read the code of agent++ and found the code below in mib.cpp.

List<MibTableRow> MibTable::get_rows(boolean discriminator)
{
 OidListCursor<MibTableRow> cur;
 List<MibTableRow> list;
 for (cur.init(&content); cur.get(); cur.next()) {
  snmpRowStatus* status = cur.get()->get_row_status();
  if ((!status) || (discriminator == 0) ||
      ((status) && (status->get() == discriminator))) {
   list.add(cur.get());
  }
 }
 return list;
}

I modified it to below , everything was OK.

List<MibTableRow>* MibTable::get_rows(boolean discriminator)
{
 OidListCursor<MibTableRow> cur;
 List<MibTableRow>* list = new List<MibTableRow>();
 for (cur.init(&content); cur.get(); cur.next()) {
  snmpRowStatus* status = cur.get()->get_row_status();
  if ((!status) || (discriminator == 0) ||
      ((status) && (status->get() == discriminator))) {
   list->add(cur.get());
  }
 }
 return list;
}

Have any one used the first piece of code without "segment fault"?
Best regards
Xu




More information about the AGENTPP mailing list