1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Compare commits

...

1 Commits

Author SHA1 Message Date
aln
9b5f0c2c08 Fixed warnings
- arrayIndexOutOfBoundsCond
- nullPointer
2022-06-30 16:00:34 +03:00
5 changed files with 21 additions and 9 deletions

View File

@@ -223,14 +223,14 @@ Standard_Boolean BinLDrivers_DocumentSection::ReadTOC (
char aBuf[THE_BUF_SIZE];
Standard_Integer aNameBufferSize;
theStream.read ((char *)&aNameBufferSize, sizeof(Standard_Integer));
if (theStream.eof() || aNameBufferSize > THE_BUF_SIZE)
if (theStream.eof() || aNameBufferSize > THE_BUF_SIZE - 1)
return Standard_False;
#ifdef DO_INVERSE
aNameBufferSize = InverseSize(aNameBufferSize);
#endif
if (aNameBufferSize > 0) {
theStream.read ((char *)&aBuf[0], (Standard_Size)aNameBufferSize);
aBuf[aNameBufferSize] = '\0';
aBuf[aNameBufferSize-1] = '\0';
theSection.myName = (Standard_CString)&aBuf[0];
uint64_t aValue[3];

View File

@@ -1731,8 +1731,10 @@ static void yy_load_buffer_state (void)
void yy_delete_buffer (YY_BUFFER_STATE b )
{
if ( ! b )
if ( ! b ) {
YY_FATAL_ERROR("out of dynamic memory in yy_delete_buffer()");
return;
}
if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
@@ -1750,6 +1752,11 @@ static void yy_load_buffer_state (void)
static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
{
if ( ! b ) {
YY_FATAL_ERROR("out of dynamic memory in yy_init_buffer()");
return;
}
int oerrno = errno;
yy_flush_buffer( b );
@@ -1777,8 +1784,10 @@ static void yy_load_buffer_state (void)
*/
void yy_flush_buffer (YY_BUFFER_STATE b )
{
if ( ! b )
if ( ! b ) {
YY_FATAL_ERROR("out of dynamic memory in yy_flush_buffer()");
return;
}
b->yy_n_chars = 0;

View File

@@ -113,11 +113,11 @@ IFSelect_SessionPilot::IFSelect_SessionPilot (const Standard_CString prompt)
continue;
}
if (nc == 0) thewordeb.SetValue (thenbwords,i);
if (nc > MAXCARS) { std::cout<<"Arg."<<thenbwords<<" > "<<MAXCARS<<" car.s, tronque"<<std::endl; continue; }
if (nc >= MAXCARS - 1) { std::cout<<"Arg."<<thenbwords<<" > "<<MAXCARS<<" car.s, tronque"<<std::endl; continue; }
unarg[nc] = val; nc ++;
}
if (nc > 0) {
unarg[nc] = '\0'; thewords(thenbwords).Clear();
unarg[nc + 1] = '\0'; thewords(thenbwords).Clear();
thewords(thenbwords).AssignCat(unarg);
#ifdef DEBUG_TRACE
std::cout<<"thewords("<<thenbwords<<")="<<unarg<<std::endl<<" .. Fin avec thenbwords="<<thenbwords+1<<std::endl;

View File

@@ -141,7 +141,7 @@ Returns : iMeter if OK, -1 if no such meter
======================================================================*/
int perf_start_imeter (const int iMeter)
{
if (iMeter >= 0 && iMeter < nb_meters) {
if (iMeter >= 0 && iMeter < nb_meters && iMeter < MAX_METERS) {
PICK_TIME (MeterTable[iMeter].start_time)
return iMeter;
}

View File

@@ -1774,6 +1774,9 @@ void yyFlexLexer::yyrestart( std::istream* input_file )
void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream& file )
{
if ( ! b )
return;
int oerrno = errno;
yy_flush_buffer( b );