garouter/gaChannel.c use of unintialized or incorrect variable

This resolution assumes that all records and values of ch->gcr_type are expected
to be one of the 3 cases in the switch.  The bug it on the first iteration it is
possible 'tot' and 'clear' is just not initializaed and on a subsequent iteration
it is possible it ot setup to the previous interation values.

SonarCloud
garouter/gaChannel.c:385:3rd function call argument is an uninitialized value
https://sonarcloud.io/project/issues?open=AZJB17fFNGfDNup0RkoE&id=dlmiles_magic
This commit is contained in:
Darryl L. Miles 2024-09-29 23:00:00 +01:00 committed by Tim Edwards
parent 543bd5a5b8
commit a9b707460b
1 changed files with 10 additions and 4 deletions

View File

@ -381,11 +381,17 @@ gaChannelStats(list)
tot = &gaTotRiverCross;
clear = &gaClearRiverCross;
break;
default: /* otherwise tot and clear is not intialized */
tot = NULL;
clear = NULL;
break;
}
if(tot && clear) {
gaPinStats(ch->gcr_tPins, ch->gcr_length, tot, clear);
gaPinStats(ch->gcr_bPins, ch->gcr_length, tot, clear);
gaPinStats(ch->gcr_lPins, ch->gcr_width, tot, clear);
gaPinStats(ch->gcr_rPins, ch->gcr_width, tot, clear);
}
gaPinStats(ch->gcr_tPins, ch->gcr_length, tot, clear);
gaPinStats(ch->gcr_bPins, ch->gcr_length, tot, clear);
gaPinStats(ch->gcr_lPins, ch->gcr_width, tot, clear);
gaPinStats(ch->gcr_rPins, ch->gcr_width, tot, clear);
}
numTot = gaTotRiverCross + gaTotNormCross;