diff options
author | Mike Lockwood <lockwood@android.com> | 2010-04-14 18:55:41 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2010-04-14 19:38:26 -0400 |
commit | a3d2d769833c7b796d073fb4002efe21142a7dc4 (patch) | |
tree | d6a9bb1661f90d6044079338dcede4a9a80ba6a3 /location | |
parent | 04598b67a58fad93e5060bb77756ba4863013aed (diff) | |
download | frameworks_base-a3d2d769833c7b796d073fb4002efe21142a7dc4.zip frameworks_base-a3d2d769833c7b796d073fb4002efe21142a7dc4.tar.gz frameworks_base-a3d2d769833c7b796d073fb4002efe21142a7dc4.tar.bz2 |
GpsStatus: Bounds check PRN to avoid array indexing exceptions.
Change-Id: Iea8b525dd8681f32cb7ce7415dad0ec665d9016d
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'location')
-rw-r--r-- | location/java/android/location/GpsStatus.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/location/java/android/location/GpsStatus.java b/location/java/android/location/GpsStatus.java index ce69ac1..4af55a6 100644 --- a/location/java/android/location/GpsStatus.java +++ b/location/java/android/location/GpsStatus.java @@ -150,15 +150,17 @@ public final class GpsStatus { for (i = 0; i < svCount; i++) { int prn = prns[i] - 1; int prnShift = (1 << prn); - GpsSatellite satellite = mSatellites[prn]; - - satellite.mValid = true; - satellite.mSnr = snrs[i]; - satellite.mElevation = elevations[i]; - satellite.mAzimuth = azimuths[i]; - satellite.mHasEphemeris = ((ephemerisMask & prnShift) != 0); - satellite.mHasAlmanac = ((almanacMask & prnShift) != 0); - satellite.mUsedInFix = ((usedInFixMask & prnShift) != 0); + if (prn >= 0 && prn < mSatellites.length) { + GpsSatellite satellite = mSatellites[prn]; + + satellite.mValid = true; + satellite.mSnr = snrs[i]; + satellite.mElevation = elevations[i]; + satellite.mAzimuth = azimuths[i]; + satellite.mHasEphemeris = ((ephemerisMask & prnShift) != 0); + satellite.mHasAlmanac = ((almanacMask & prnShift) != 0); + satellite.mUsedInFix = ((usedInFixMask & prnShift) != 0); + } } } |