Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ExternalConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ char *command_completion(const char *text, int state)
}

wxString test(wxString(text, *wxConvCurrent).Lower());
while (nextCommand != curCommands->end()) {
while (curCommands && (nextCommand != curCommands->end())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation for rl_completion_matches says that entry_func (i.e. command_completion() in this case) will first be called with state being zero on the first call, and non-zero on subsequent calls. Thus curCommands (and nextCommand, too) will always be initialized and non-zero on calls where state is non-zero.

wxString curTest = (*nextCommand)->GetCommand();
++nextCommand;
if (curTest.Lower().StartsWith(test)) {
Expand Down
2 changes: 1 addition & 1 deletion src/KnownFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ void CKnownFile::CreateOfferedFilePacket(
tags.push_back(new CTagInt32(FT_FILESIZE_HI, (uint32)(GetFileSize() >> 32)));
}
} else {
if (!pClient->SupportsLargeFiles()) {
if (pClient && (!pClient->SupportsLargeFiles())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wxASSERT call on line 1093 properly checks for both pClient and pServer being non-null. However, only in debug builds (wxDEBUG enabled). That should be changed to something that works also in release builds (like wxCHECK_RET) and further checks can be omitted.

wxFAIL;
tags.push_back(new CTagInt32(FT_FILESIZE, 0));
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/SharedFileList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ void CSharedFileList::SendListToServer(){
// - this function is called once when connecting to a server and when a file becomes shareable - so, it's called rarely.
// - if the compressed size is still >= the original size, we send the uncompressed packet
// therefor we always try to compress the packet
if (server->GetTCPFlags() & SRV_TCPFLG_COMPRESSION){
if (server && (server->GetTCPFlags() & SRV_TCPFLG_COMPRESSION)){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, this function should only be called when we're connected to a server. But just in case, if we are not connected (i.e. GetCurrentServer() returns NULL on line 707) we could bail out immediately, because SendPacket() will fail anyway at the end of the function. Of course that would render all further checks for server being non-null obsolete.

packet->PackPacket();
}

Expand Down