Open fighting300 opened 2 weeks ago
`
the code of mqtt is blow:
(void)sendMessageData:(id)data ToTopic:(NSString )topic userProperty:(nullable NSDictionary )userInfo{ dispatch_async(self.customQueue, ^{ NSError error = nil; NSString dataStr = nil; // 将 NSDictionary,NSArray 再转为JSON 数据 if([data isKindOfClass:[NSDictionary class]]||[data isKindOfClass:[NSArray class]]) { NSData jsonData = [NSJSONSerialization dataWithJSONObject:data options:NSJSONWritingPrettyPrinted error:&error]; if (jsonData) { // 将 JSON 数据转换为字符串 dataStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; } } else if([data isKindOfClass:[NSString class]]) { dataStr = (NSString )data; }
[self.pubProp setUserProperty:userProps]; if (dataStr && topic ) { NSInteger ret = [self.mqtt5 publish:topic withString:dataStr qos:CocoaMQTTQoSQos0 DUP:NO retained:NO properties:self.pubProp]; if (ret == -1) { [MQTTClientManager reportMqttLogs:@{@"messageTopic": topic } withId:@"messageBlock" withTime:nil type:nil]; } }
}); } `
how can this happen the "pubProps" is not release
it seems crash in blow code
` func properties() -> [UInt8] {
// Properties return publishProperties?.properties ?? [] } public var properties: [UInt8] { var properties = [UInt8]() //3.3.2.3.2 Payload Format Indicator if let payloadFormatIndicator = self.payloadFormatIndicator { properties += getMQTTPropertyData(type: CocoaMQTTPropertyName.payloadFormatIndicator.rawValue, value: [payloadFormatIndicator.rawValue]) } //3.3.2.3.3 Message Expiry Interval if let messageExpiryInterval = self.messageExpiryInterval { properties += getMQTTPropertyData(type: CocoaMQTTPropertyName.willExpiryInterval.rawValue, value: messageExpiryInterval.byteArrayLittleEndian) } //3.3.2.3.4 Topic Alias if let topicAlias = self.topicAlias { properties += getMQTTPropertyData(type: CocoaMQTTPropertyName.topicAlias.rawValue, value: topicAlias.hlBytes) } //3.3.2.3.5 Response Topic if let responseTopic = self.responseTopic { properties += getMQTTPropertyData(type: CocoaMQTTPropertyName.responseTopic.rawValue, value: responseTopic.bytesWithLength) } //3.3.2.3.6 Correlation Data if let correlationData = self.correlationData { properties += getMQTTPropertyData(type: CocoaMQTTPropertyName.correlationData.rawValue, value: correlationData) } //3.3.2.3.7 Property Length User Property if let userProperty = self.userProperty { for (key, value) in userProperty { properties += getMQTTPropertyData(type: CocoaMQTTPropertyName.userProperty.rawValue, value: key.bytesWithLength + value.bytesWithLength) } } //3.3.2.3.8 Subscription Identifier if let subscriptionIdentifier = self.subscriptionIdentifier, let subscriptionIdentifier = beVariableByteInteger(subscriptionIdentifier) { properties += getMQTTPropertyData(type: CocoaMQTTPropertyName.subscriptionIdentifier.rawValue, value: subscriptionIdentifier) } //3.3.2.3.9 Content Type if let contentType = self.contentType { properties += getMQTTPropertyData(type: CocoaMQTTPropertyName.contentType.rawValue, value: contentType.bytesWithLength) } return properties }
@leeway1208 @HJianBo
![Uploading 4eb03c20-39c4-106a-aaa1-910f0da557be.jpg…]()
hello, i find a crash when send message; the ips info is blow: example 1: ` SIGSEGV: 0xffffff818ac549e0 0x0 + 6619471872
`
example 2: ` SIGSEGV: 0x0000000101287e18 $s11CommonKit_a21MqttPublishPropertiesC10propertiesSays5UInt8VGvg
`
the code of mqtt is blow:
`
(void)sendMessageData:(id)data ToTopic:(NSString )topic userProperty:(nullable NSDictionary )userInfo{ dispatch_async(self.customQueue, ^{ NSError error = nil; NSString dataStr = nil; // 将 NSDictionary,NSArray 再转为JSON 数据 if([data isKindOfClass:[NSDictionary class]]||[data isKindOfClass:[NSArray class]]) { NSData jsonData = [NSJSONSerialization dataWithJSONObject:data options:NSJSONWritingPrettyPrinted error:&error]; if (jsonData) { // 将 JSON 数据转换为字符串 dataStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; } } else if([data isKindOfClass:[NSString class]]) { dataStr = (NSString )data; }
}); } `
how can this happen the "pubProps" is not release
it seems crash in blow code
` func properties() -> [UInt8] {
`