|
2 | 2 | #import "SentryBaggage.h"
|
3 | 3 | #import "SentryDefines.h"
|
4 | 4 | #import "SentryDsn.h"
|
| 5 | +#import "SentryInternalDefines.h" |
5 | 6 | #import "SentryLogC.h"
|
6 | 7 | #import "SentryOptions+Private.h"
|
7 | 8 | #import "SentrySampleDecision.h"
|
@@ -78,17 +79,17 @@ - (nullable instancetype)initWithScope:(SentryScope *)scope options:(SentryOptio
|
78 | 79 | SentryTracer *tracer = [SentryTracer getTracer:scope.span];
|
79 | 80 | if (tracer == nil) {
|
80 | 81 | return nil;
|
81 |
| - } else { |
82 |
| - return [self initWithTracer:tracer scope:scope options:options]; |
83 | 82 | }
|
| 83 | + return [self initWithTracer:tracer scope:scope options:options]; |
84 | 84 | }
|
85 | 85 |
|
86 | 86 | - (nullable instancetype)initWithTracer:(SentryTracer *)tracer
|
87 | 87 | scope:(nullable SentryScope *)scope
|
88 | 88 | options:(SentryOptions *)options
|
89 | 89 | {
|
90 |
| - if (tracer.traceId == nil || options.parsedDsn == nil) |
| 90 | + if (tracer.traceId == nil || options.parsedDsn == nil) { |
91 | 91 | return nil;
|
| 92 | + } |
92 | 93 |
|
93 | 94 | #if !SDK_V9
|
94 | 95 | NSString *userSegment = nil;
|
@@ -154,7 +155,14 @@ - (instancetype)initWithTraceId:(SentryId *)traceId
|
154 | 155 |
|
155 | 156 | - (nullable instancetype)initWithDict:(NSDictionary<NSString *, id> *)dictionary
|
156 | 157 | {
|
157 |
| - SentryId *traceId = [[SentryId alloc] initWithUUIDString:dictionary[@"trace_id"]]; |
| 158 | + NSString *_Nullable rawTraceId = dictionary[@"trace_id"]; |
| 159 | + if (rawTraceId == nil || ![rawTraceId isKindOfClass:[NSString class]]) { |
| 160 | + SENTRY_LOG_ERROR(@"Invalid trace_id: %@", rawTraceId); |
| 161 | + return nil; |
| 162 | + } |
| 163 | + |
| 164 | + SentryId *traceId = |
| 165 | + [[SentryId alloc] initWithUUIDString:SENTRY_UNWRAP_NULLABLE(NSString, rawTraceId)]; |
158 | 166 | NSString *publicKey = dictionary[@"public_key"];
|
159 | 167 | if (traceId == nil || publicKey == nil)
|
160 | 168 | return nil;
|
|
0 commit comments