fix(darwin): logging - potential crash due to mishandled string formats (#286)

This commit is contained in:
Nathan Van Fleet
2022-05-20 07:22:33 -07:00
committed by GitHub
parent 7e133e3bdf
commit c762d231ea
3 changed files with 7 additions and 17 deletions

View File

@@ -20,9 +20,9 @@ NS_ASSUME_NONNULL_BEGIN
- (void)stopDownloadEventForResponse:(NSURLResponse *)response;
- (void)debugLog:(NSString *)format, ...;
- (void)debugLog:(NSString *)message;
- (void)errorLog:(NSString *)format, ...;
- (void)errorLog:(NSString *)message;
@end

View File

@@ -286,7 +286,7 @@ std::unique_ptr<AsyncRequest> HTTPFileSource::request(const Resource& resource,
using Error = Response::Error;
if (error) {
[MGLNativeNetworkManager.sharedManager errorLog:@"Requesting: %@ failed with error: %@", res.URL.relativePath, error];
[MGLNativeNetworkManager.sharedManager errorLog:@"Requesting: %@ failed with error: %@", req.URL, error.debugDescription];
if (data) {
response.data =

View File

@@ -121,22 +121,12 @@ NSString * const kMGLDownloadPerformanceEvent = @"mobile.performance_trace";
[self sendEventForURLResponse:response withAction:@"cancel"];
}
- (void)debugLog:(NSString *)format, ... {
va_list formatList;
va_start(formatList, format);
NSString *formattedMessage = [[NSString alloc] initWithFormat:format arguments:formatList];
va_end(formatList);
MGLLogDebug(formattedMessage);
- (void)debugLog:(NSString *)message {
MGLLogDebug(message);
}
- (void)errorLog:(NSString *)format, ... {
va_list formatList;
va_start(formatList, format);
NSString *formattedMessage = [[NSString alloc] initWithFormat:format arguments:formatList];
va_end(formatList);
MGLLogError(formattedMessage);
- (void)errorLog:(NSString *)message {
MGLLogError(message);
}
#pragma mark - Event management