Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added string length check before parsing data into JSONObject. #122

Merged
merged 3 commits into from
Dec 11, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions library/src/com/anjlab/android/iab/v3/BillingProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,12 @@ private boolean loadPurchasesByType(String type, BillingCache cacheStorage) {
if (purchaseList != null)
for (int i = 0; i < purchaseList.size(); i++) {
String jsonData = purchaseList.get(i);
JSONObject purchase = new JSONObject(jsonData);
String signature = signatureList != null && signatureList.size() > i ? signatureList.get(i) : null;
cacheStorage.put(purchase.getString(Constants.RESPONSE_PRODUCT_ID), jsonData, signature);

if( jsonData.length() > 0 ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about using TextUtils.isEmpty here?

JSONObject purchase = new JSONObject(jsonData);
String signature = signatureList != null && signatureList.size() > i ? signatureList.get(i) : null;
cacheStorage.put(purchase.getString(Constants.RESPONSE_PRODUCT_ID), jsonData, signature);
}
}
}
return true;
Expand Down