Merge pull request #27 from defold/Issue-26-crash-on-free-empty-static-string

Allocate empty string when title is missing to have the same code path in both cases
This commit is contained in:
Björn Ritzl 2020-08-20 13:12:30 +02:00 committed by GitHub
commit 906a4679e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -125,14 +125,14 @@ static void IAP_FreeTransaction(IAPTransaction* transaction)
} }
else { else {
dmLogWarning("Product %s has no localizedTitle", [p.productIdentifier UTF8String]); dmLogWarning("Product %s has no localizedTitle", [p.productIdentifier UTF8String]);
product.title = ""; product.title = strdup("");
} }
if (p.localizedDescription) { if (p.localizedDescription) {
product.description = strdup([p.localizedDescription UTF8String]); product.description = strdup([p.localizedDescription UTF8String]);
} }
else { else {
dmLogWarning("Product %s has no localizedDescription", [p.productIdentifier UTF8String]); dmLogWarning("Product %s has no localizedDescription", [p.productIdentifier UTF8String]);
product.description = ""; product.description = strdup("");
} }
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;