corrected possible invalid write

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3640 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-10-07 19:25:40 +00:00
parent 6f5c556539
commit 3b2ab05993

View File

@ -305,9 +305,9 @@ int bdNodeManager::checkStatus()
case BITDHT_QUERY_QUERYING: case BITDHT_QUERY_QUERYING:
{ {
#ifdef DEBUG_MGR #ifdef DEBUG_MGR
std::cerr << "bdNodeManager::checkStatus() Query in Progress id: "; std::cerr << "bdNodeManager::checkStatus() Query in Progress id: ";
mFns->bdPrintNodeId(std::cerr, &(it->first)); mFns->bdPrintNodeId(std::cerr, &(it->first));
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
} }
break; break;
@ -315,9 +315,9 @@ int bdNodeManager::checkStatus()
case BITDHT_QUERY_FAILURE: case BITDHT_QUERY_FAILURE:
{ {
#ifdef DEBUG_MGR #ifdef DEBUG_MGR
std::cerr << "bdNodeManager::checkStatus() Query Failed: id: "; std::cerr << "bdNodeManager::checkStatus() Query Failed: id: ";
mFns->bdPrintNodeId(std::cerr, &(it->first)); mFns->bdPrintNodeId(std::cerr, &(it->first));
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
// BAD. // BAD.
doRemove = true; doRemove = true;
@ -329,11 +329,11 @@ int bdNodeManager::checkStatus()
case BITDHT_QUERY_FOUND_CLOSEST: case BITDHT_QUERY_FOUND_CLOSEST:
{ {
#ifdef DEBUG_MGR #ifdef DEBUG_MGR
std::cerr << "bdNodeManager::checkStatus() Found Closest: id: "; std::cerr << "bdNodeManager::checkStatus() Found Closest: id: ";
mFns->bdPrintNodeId(std::cerr, &(it->first)); mFns->bdPrintNodeId(std::cerr, &(it->first));
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
doRemove = true; doRemove = true;
doCallback = true; doCallback = true;
callbackStatus = BITDHT_MGR_QUERY_PEER_OFFLINE; callbackStatus = BITDHT_MGR_QUERY_PEER_OFFLINE;
@ -343,11 +343,11 @@ int bdNodeManager::checkStatus()
case BITDHT_QUERY_PEER_UNREACHABLE: case BITDHT_QUERY_PEER_UNREACHABLE:
{ {
#ifdef DEBUG_MGR #ifdef DEBUG_MGR
std::cerr << "bdNodeManager::checkStatus() the Peer Online but Unreachable: id: "; std::cerr << "bdNodeManager::checkStatus() the Peer Online but Unreachable: id: ";
mFns->bdPrintNodeId(std::cerr, &(it->first)); mFns->bdPrintNodeId(std::cerr, &(it->first));
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
doRemove = true; doRemove = true;
doCallback = true; doCallback = true;
callbackStatus = BITDHT_MGR_QUERY_PEER_UNREACHABLE; callbackStatus = BITDHT_MGR_QUERY_PEER_UNREACHABLE;
@ -357,9 +357,9 @@ int bdNodeManager::checkStatus()
case BITDHT_QUERY_SUCCESS: case BITDHT_QUERY_SUCCESS:
{ {
#ifdef DEBUG_MGR #ifdef DEBUG_MGR
std::cerr << "bdNodeManager::checkStatus() Found Query: id: "; std::cerr << "bdNodeManager::checkStatus() Found Query: id: ";
mFns->bdPrintNodeId(std::cerr, &(it->first)); mFns->bdPrintNodeId(std::cerr, &(it->first));
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
//foundId = //foundId =
doRemove = true; doRemove = true;
@ -404,41 +404,44 @@ int bdNodeManager::checkStatus()
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
} }
else if (pit->second.mStatus == it->second.mStatus) else
{ {
/* status is unchanged */ if (pit->second.mStatus == it->second.mStatus)
doPing = false;
doCallback = false;
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::checkStatus() Status unchanged for : ";
mFns->bdPrintNodeId(std::cerr, &(it->first));
std::cerr << " status: " << it->second.mStatus;
std::cerr << std::endl;
#endif
}
else
{
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::checkStatus() Updating External Status for : ";
mFns->bdPrintNodeId(std::cerr, &(it->first));
std::cerr << " to: " << it->second.mStatus;
std::cerr << std::endl;
#endif
/* update status */
pit->second.mStatus = it->second.mStatus;
}
if (doSaveAddress)
{
if (it->second.mResults.size() > 0)
{ {
pit->second.mDhtAddr = it->second.mResults.front().addr; /* status is unchanged */
doPing = false;
doCallback = false;
#ifdef DEBUG_MGR
std::cerr << "bdNodeManager::checkStatus() Status unchanged for : ";
mFns->bdPrintNodeId(std::cerr, &(it->first));
std::cerr << " status: " << it->second.mStatus;
std::cerr << std::endl;
#endif
} }
else else
{ {
pit->second.mDhtAddr.sin_addr.s_addr = 0;
pit->second.mDhtAddr.sin_port = 0; #ifdef DEBUG_MGR
std::cerr << "bdNodeManager::checkStatus() Updating External Status for : ";
mFns->bdPrintNodeId(std::cerr, &(it->first));
std::cerr << " to: " << it->second.mStatus;
std::cerr << std::endl;
#endif
/* update status */
pit->second.mStatus = it->second.mStatus;
}
if (doSaveAddress)
{
if (it->second.mResults.size() > 0)
{
pit->second.mDhtAddr = it->second.mResults.front().addr;
}
else
{
pit->second.mDhtAddr.sin_addr.s_addr = 0;
pit->second.mDhtAddr.sin_port = 0;
}
} }
} }