Skip to content

Commit

Permalink
Fixed a possible NPE due to auto boxing.
Browse files Browse the repository at this point in the history
  • Loading branch information
jawi committed Oct 23, 2010
1 parent b7dac52 commit 3e81d9e
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ protected ClockStats doInBackground() throws Exception
int start = context.getStartSampleIndex();
int end = context.getEndSampleIndex();

// Make sure no other stuff from previous runs keep lingering...
this.stats.get( Edge.RISING ).clear();
this.stats.get( Edge.FALLING ).clear();

int i = Math.max( 0, start - 1 );
long lastTransition = 0;
int lastBitValue = values[i] & this.channelMask;
Expand Down Expand Up @@ -179,9 +183,10 @@ protected ClockStats doInBackground() throws Exception
lastBitValue = bitValue;
}

final int bestRising = this.stats.get( Edge.RISING ).getHighestRanked();
final int bestFalling = this.stats.get( Edge.FALLING ).getHighestRanked();
final Integer bestRising = this.stats.get( Edge.RISING ).getHighestRanked();
final Integer bestFalling = this.stats.get( Edge.FALLING ).getHighestRanked();

return new ClockStats( bestRising, bestFalling, getSampleRate() );
return new ClockStats( ( bestRising == null ) ? 0 : bestRising.intValue(), //
( bestFalling == null ) ? 0 : bestFalling.intValue(), getSampleRate() );
}
}

0 comments on commit 3e81d9e

Please sign in to comment.