Merge pull request #20 from defold/Issue-18-crash-on-empty-product

Check if title or description is null
This commit is contained in:
Björn Ritzl 2020-03-09 12:33:48 +01:00 committed by GitHub
commit f1d53948e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,8 +119,20 @@ static void IAP_FreeTransaction(IAPTransaction* transaction)
IAPProduct product = {0}; IAPProduct product = {0};
product.ident = strdup([p.productIdentifier UTF8String]); product.ident = strdup([p.productIdentifier UTF8String]);
product.title = strdup([p.localizedTitle UTF8String]); if (p.localizedTitle) {
product.description = strdup([p.localizedDescription UTF8String]); product.title = strdup([p.localizedTitle UTF8String]);
}
else {
dmLogWarning("Product %s has no localizedTitle", [p.productIdentifier UTF8String]);
product.title = "";
}
if (p.localizedDescription) {
product.description = strdup([p.localizedDescription UTF8String]);
}
else {
dmLogWarning("Product %s has no localizedDescription", [p.productIdentifier UTF8String]);
product.description = "";
}
product.currency_code = strdup([[p.priceLocale objectForKey:NSLocaleCurrencyCode] UTF8String]); product.currency_code = strdup([[p.priceLocale objectForKey:NSLocaleCurrencyCode] UTF8String]);
product.price = p.price.floatValue; product.price = p.price.floatValue;