Skip to content

Commit acf1c93

Browse files
authored
Merge pull request #1229 from smartdevicelink/bugfix/issue_1227
Fix potential overflow issue in BestRouterComparator
2 parents 50ce223 + e24ee33 commit acf1c93

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

android/sdl_android/src/main/java/com/smartdevicelink/util/SdlAppInfo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@ public int compare(SdlAppInfo one, SdlAppInfo two) {
153153
int versionCompare = two.routerServiceVersion - one.routerServiceVersion;
154154

155155
if(versionCompare == 0){ //Versions are equal so lets use the one that has been updated most recently
156-
int updateTime = (int)(two.lastUpdateTime - one.lastUpdateTime);
156+
long updateTime = two.lastUpdateTime - one.lastUpdateTime;
157157
if(updateTime == 0){
158158
//This is arbitrary, but we want to ensure all lists are sorted in the same order
159159
return one.routerServiceComponentName.getPackageName().compareTo(two.routerServiceComponentName.getPackageName());
160160
}else{
161-
return updateTime;
161+
return (updateTime < 0 ? -1 : 1);
162162
}
163163
}else{
164-
return versionCompare;
164+
return (versionCompare < 0 ? -1 : 1);
165165
}
166166

167167
}else{

0 commit comments

Comments
 (0)