aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNelson Billing <nbilling@google.com>2020-09-09 14:39:32 -0700
committerNelson Billing <nbilling@google.com>2020-09-09 22:07:06 +0000
commit9c4671f2e3a63c0f155d9b2511192d0b5fa7f760 (patch)
tree83c626021a72d4838ce3d570963cad0864f30f77
parentfile_id_unittest: avoid system() (diff)
downloadbreakpad-9c4671f2e3a63c0f155d9b2511192d0b5fa7f760.tar.xz
Change JSON serialization error check.
- Mac OS symupload used to check for errors in JSON serialization by inspecting the "error" out parameter of the serialization function. Now it checks the returned data for "nil". - Similar change for the HTTP request that's made in the same function. Change-Id: I86f50ef44e60ee119c302e0614b115a8d35e9b5b Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2390753 Reviewed-by: Mark Mentovai <mark@chromium.org>
-rw-r--r--src/common/mac/SymbolCollectorClient.m17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/common/mac/SymbolCollectorClient.m b/src/common/mac/SymbolCollectorClient.m
index b135cdeb..5926d2ad 100644
--- a/src/common/mac/SymbolCollectorClient.m
+++ b/src/common/mac/SymbolCollectorClient.m
@@ -202,32 +202,37 @@
NSDictionary* jsonDictionary = [NSDictionary
dictionaryWithObjectsAndKeys:symbolIdDictionary, @"symbol_id", type,
@"symbol_upload_type", nil];
- NSError* error;
+ NSError* error = nil;
NSData* jsonData =
[NSJSONSerialization dataWithJSONObject:jsonDictionary
options:NSJSONWritingPrettyPrinted
error:&error];
- if (error) {
+ if (jsonData == nil) {
+ fprintf(stdout, "Error: %s\n", [[error localizedDescription] UTF8String]);
fprintf(stdout,
"Failed to complete upload. Could not write JSON payload.\n");
return CompleteUploadResultError;
}
+
NSString* body = [[NSString alloc] initWithData:jsonData
encoding:NSUTF8StringEncoding];
-
HTTPSimplePostRequest* postRequest =
[[HTTPSimplePostRequest alloc] initWithURL:URL];
[postRequest setBody:body];
[postRequest setContentType:@"application/json"];
- error = nil;
NSData* data = [postRequest send:&error];
+ if (data == nil) {
+ fprintf(stdout, "Error: %s\n", [[error localizedDescription] UTF8String]);
+ fprintf(stdout, "Failed to complete upload URL.\n");
+ return CompleteUploadResultError;
+ }
+
NSString* result = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
int responseCode = [[postRequest response] statusCode];
[postRequest release];
-
- if (error || responseCode != 200) {
+ if (responseCode != 200) {
fprintf(stdout, "Failed to complete upload URL.\n");
fprintf(stdout, "Response code: %d\n", responseCode);
fprintf(stdout, "Response:\n");