systers / FirstAide-Android

FirstAide is a application to help the Peace Corps Volunteers who are victims of sexual harassment.
23 stars 104 forks source link

Resource Leaks, Null Deferences using FbInfer Tool #448

Open codingblazer opened 7 years ago

codingblazer commented 7 years ago

I tested the app using Facebook infer tool which got Open Sourced recently for analysing the app. The following leaks and deferences were found -

app/src/main/java/com/peacecorps/pcsa/circle_of_trust/CircleOfTrustFragment.java:369: error: NULL_DEREFERENCE
  object CircleOfTrustFragment.phoneNumbers last assigned on line 356 could be null and is dereferenced at line 369
  367.                       editor.putString(NAME_KEY + i,phoneNumbers[i]);
  368.                   }
  369. >                 if(phoneNumbers[i].isEmpty()) {
  370.                       allTextViews[i].setText(getString(R.string.unregistered));
  371.                       editor.putString(NAME_KEY + i,getString(R.string.unregistered));

app/src/main/java/com/peacecorps/pcsa/circle_of_trust/MessageDialogBox.java:52: error: CONTEXT_LEAK
  Context class android.app.Activity may leak during method com.peacecorps.pcsa.circle_of_trust.MessageDialogBox.newInstance:
  Static field com.peacecorps.pcsa.circle_of_trust.MessageDialogBox.context |->
  Leaked class android.app.Activity
  50.           context = activity;
  51.           MessageDialogBox messageDialogBox = new MessageDialogBox();
  52. >         return messageDialogBox;
  53.       }
  54.   

app/src/main/java/com/peacecorps/pcsa/circle_of_trust/Trustees.java:232: error: RESOURCE_LEAK
   resource of type android.database.sqlite.SQLiteCursor acquired to cursor by call to query(...) at line 213 is not released after line 232
  230.               } finally {
  231.                   if (cursor != null) {
  232. >                     cursor.close();
  233.                   }
  234. 

@sandarumk If this seems valid to you, feel free to tag this as a free issue. Thanks