Skip to content

Commit

Permalink
Fix bounds checks in FGFCS (JSBSim-Team#1191)
Browse files Browse the repository at this point in the history
  • Loading branch information
roccoblues authored and bcoconni committed Nov 24, 2024
1 parent bb4cd5b commit 1dc9e11
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/models/FGFCS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ void FGFCS::SetDspPos( int form , double pos )

void FGFCS::SetThrottleCmd(int engineNum, double setting)
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < (int)ThrottleCmd.size()) {
if (engineNum < 0) {
for (unsigned int ctr=0; ctr<ThrottleCmd.size(); ctr++)
ThrottleCmd[ctr] = setting;
Expand Down Expand Up @@ -357,7 +357,7 @@ void FGFCS::SetThrottlePos(int engineNum, double setting)

double FGFCS::GetThrottleCmd(int engineNum) const
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < (int)ThrottleCmd.size()) {
if (engineNum < 0) {
FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR);
log << "Cannot get throttle value for ALL engines" << endl;
Expand Down Expand Up @@ -397,7 +397,7 @@ double FGFCS::GetThrottlePos(int engineNum) const

void FGFCS::SetMixtureCmd(int engineNum, double setting)
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < (int)MixtureCmd.size()) {
if (engineNum < 0) {
for (unsigned int ctr=0; ctr<MixtureCmd.size(); ctr++)
MixtureCmd[ctr] = setting;
Expand All @@ -411,7 +411,7 @@ void FGFCS::SetMixtureCmd(int engineNum, double setting)

void FGFCS::SetMixturePos(int engineNum, double setting)
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < (int)MixturePos.size()) {
if (engineNum < 0) {
for (unsigned int ctr=0; ctr<MixtureCmd.size(); ctr++)
MixturePos[ctr] = MixtureCmd[ctr];
Expand All @@ -425,7 +425,7 @@ void FGFCS::SetMixturePos(int engineNum, double setting)

void FGFCS::SetPropAdvanceCmd(int engineNum, double setting)
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < (int)PropAdvanceCmd.size()) {
if (engineNum < 0) {
for (unsigned int ctr=0; ctr<PropAdvanceCmd.size(); ctr++)
PropAdvanceCmd[ctr] = setting;
Expand All @@ -439,7 +439,7 @@ void FGFCS::SetPropAdvanceCmd(int engineNum, double setting)

void FGFCS::SetPropAdvance(int engineNum, double setting)
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < (int)PropAdvance.size()) {
if (engineNum < 0) {
for (unsigned int ctr=0; ctr<PropAdvanceCmd.size(); ctr++)
PropAdvance[ctr] = PropAdvanceCmd[ctr];
Expand All @@ -453,7 +453,7 @@ void FGFCS::SetPropAdvance(int engineNum, double setting)

void FGFCS::SetFeatherCmd(int engineNum, bool setting)
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < (int)PropFeatherCmd.size()) {
if (engineNum < 0) {
for (unsigned int ctr=0; ctr<PropFeatherCmd.size(); ctr++)
PropFeatherCmd[ctr] = setting;
Expand All @@ -467,7 +467,7 @@ void FGFCS::SetFeatherCmd(int engineNum, bool setting)

void FGFCS::SetPropFeather(int engineNum, bool setting)
{
if (engineNum < (int)ThrottlePos.size()) {
if (engineNum < (int)PropFeather.size()) {
if (engineNum < 0) {
for (unsigned int ctr=0; ctr<PropFeatherCmd.size(); ctr++)
PropFeather[ctr] = PropFeatherCmd[ctr];
Expand Down

0 comments on commit 1dc9e11

Please sign in to comment.