New issue
Advanced search Search tips

Issue 807733 link

Starred by 1 user

Issue metadata

Status: Unconfirmed
Owner: ----
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug



Sign in to add a comment

Incorrect String Comparison

Reported by wangsong...@gmail.com, Jan 31 2018

Issue description

UserAgent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
Platform: chrome://android

Steps to reproduce the problem:
Our tool DeepTect has detected several incorrect String comparison issues:

Path: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java

Code:

private static boolean isCachedPage(OfflinePageItem offlinePage) {
  assert offlinePage != null;
  String namespace = offlinePage.getClientId().getNamespace();

return namespace != OfflinePageBridge.DOWNLOAD_NAMESPACE
&& namespace != OfflinePageBridge.ASYNC_NAMESPACE
&& namespace != OfflinePageBridge.BROWSER_ACTIONS_NAMESPACE;

}

Path:

third_party/jmake/src/org/pantsbuild/jmake/CompatibilityChecker.java 

Code: 

String oMName, oMSig, nMName, nMSig;
...

if (oMName == nMNames[k] && oMSig == nMSignatures[k]) {
...
}

...

String newMName = nMNames[i];
final String newMSig = nMSignatures[i];
...
if (newMName == oMNames[j] && newMSig == oMSignatures[j]) {
...
}

Using "==" or "!=" to compare two Strings is not a good practice and may introduce unintended bugs. To fix these issues, developers should use the function "equals()" to compare two Strings.

What is the expected behavior?

What went wrong?
Using "==" or "!=" to compare two Strings is not a good practice and may introduce unintended bugs. To fix these issues, developers should use the function "equals()" to compare two Strings.

Did this work before? N/A 

Chrome version: 63.0.3239.132  Channel: n/a
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version:
 
Components: Platform>ARC
Components: Platform>Apps>ARC

Sign in to add a comment