More safety for array access.

Fixes https://gitlab.com/kicad/code/kicad/issues/13583
This commit is contained in:
Jeff Young 2023-01-23 18:42:36 +00:00
parent d9e1763484
commit 4e50c5313d
2 changed files with 5 additions and 4 deletions

View File

@ -764,7 +764,7 @@ bool SIM_PLOT_FRAME::updatePlot( const wxString& aName, SIM_PLOT_TYPE aType,
else if( aType & SPT_AC_PHASE )
data_y = m_simulator->GetPhasePlot( (const char*) aName.c_str() );
else
wxASSERT_MSG( false, wxT( "Plot type missing AC_PHASE or AC_MAG bit" ) );
wxFAIL_MSG( wxT( "Plot type missing AC_PHASE or AC_MAG bit" ) );
break;
@ -775,10 +775,11 @@ bool SIM_PLOT_FRAME::updatePlot( const wxString& aName, SIM_PLOT_TYPE aType,
break;
default:
wxASSERT_MSG( false, wxT( "Unhandled plot type" ) );
return false;
wxFAIL_MSG( wxT( "Unhandled plot type" ) );
}
wxCHECK_MSG( data_y.size() >= size, false, wxT( "No (or not enough) y data values to plot" ) );
// If we did a two-source DC analysis, we need to split the resulting vector and add traces
// for each input step
SPICE_DC_PARAMS source1, source2;

View File

@ -91,7 +91,7 @@ bool SIM_WORKBOOK::AddTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aTitle,
const wxString& aName, int aPoints, const double* aX, const double* aY,
SIM_PLOT_TYPE aType )
{
if( aPlotPanel->addTrace( aTitle, aName, aPoints, aX, aY, aType ) )
if( aPoints && aPlotPanel->addTrace( aTitle, aName, aPoints, aX, aY, aType ) )
{
setModified();
return true;