Merge branch with several fixes for Coverity 8.5 warnings

See https://github.com/wxWidgets/wxWidgets/pull/505
This commit is contained in:
Vadim Zeitlin 2017-06-22 01:35:37 +02:00
commit 16252f1299
5 changed files with 12 additions and 2 deletions

View File

@ -1428,6 +1428,7 @@ void wxQuantize::DoQuantize(unsigned w, unsigned h, unsigned char **in_rows, uns
j_decompress dec; j_decompress dec;
my_cquantize_ptr cquantize; my_cquantize_ptr cquantize;
dec.colormap = NULL;
dec.output_width = w; dec.output_width = w;
dec.desired_number_of_colors = desiredNoColours; dec.desired_number_of_colors = desiredNoColours;
prepare_range_limit_table(&dec); prepare_range_limit_table(&dec);

View File

@ -685,7 +685,8 @@ int wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argpt
// VsnprintfTestCase reveals that glibc's implementation of vswprintf // VsnprintfTestCase reveals that glibc's implementation of vswprintf
// doesn't nul terminate on truncation. // doesn't nul terminate on truncation.
str[size - 1] = 0; if ( size )
str[size - 1] = 0;
return rv; return rv;
} }

View File

@ -446,6 +446,7 @@ private:
case Field_Max: case Field_Max:
wxFAIL_MSG( "Invalid field" ); wxFAIL_MSG( "Invalid field" );
return;
} }
UpdateText(); UpdateText();
@ -531,6 +532,7 @@ private:
case Field_AMPM: case Field_AMPM:
case Field_Max: case Field_Max:
wxFAIL_MSG( "Invalid field" ); wxFAIL_MSG( "Invalid field" );
return;
} }
if ( moveToNextField && m_currentField < Field_Sec ) if ( moveToNextField && m_currentField < Field_Sec )

View File

@ -559,6 +559,7 @@ wxDialUpManagerImpl::NetConnection wxDialUpManagerImpl::CheckConnect()
serv_addr.sin_family = hp->h_addrtype; serv_addr.sin_family = hp->h_addrtype;
memcpy(&serv_addr.sin_addr,hp->h_addr, hp->h_length); memcpy(&serv_addr.sin_addr,hp->h_addr, hp->h_length);
serv_addr.sin_port = htons(m_BeaconPort); serv_addr.sin_port = htons(m_BeaconPort);
memset(&serv_addr.sin_zero, 0, sizeof(serv_addr.sin_zero));
int sockfd; int sockfd;
if( ( sockfd = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0) if( ( sockfd = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0)

View File

@ -1209,7 +1209,12 @@ wxMemorySize wxGetFreeMemory()
{ {
unsigned long cached; unsigned long cached;
if ( sscanf(buf, "Cached: %lu", &cached) == 1 ) if ( sscanf(buf, "Cached: %lu", &cached) == 1 )
memFree += cached; {
if ( cached > ULONG_MAX-memFree )
memFree = ULONG_MAX;
else
memFree += cached;
}
} }
// values here are always expressed in kB and we want bytes // values here are always expressed in kB and we want bytes