Skip to content

Commit 568b44e

Browse files
authored
Merge pull request #473 from cordova-rtc/bugs/candidateToJson
fix possible TypeError: null is not an object (evaluating 'iceCandidateFields.foundation') due fail match candidateToJson
2 parents 3233544 + 5e01ae1 commit 568b44e

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

dist/cordova-plugin-iosrtc.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,18 +1655,20 @@ function RTCIceCandidate(data) {
16551655
// Parse candidate SDP:
16561656
// Example: candidate:1829696681 1 udp 2122262783 2a01:cb05:8d3e:a300:e1ad:79c1:7096:8ba0 49778 typ host generation 0 ufrag c9L6 network-id 2 network-cost 10
16571657
var iceCandidateFields = candidateToJson(this.candidate);
1658-
this.foundation = iceCandidateFields.foundation;
1659-
this.component = iceCandidateFields.componentId;
1660-
this.priority = iceCandidateFields.priority;
1661-
this.type = iceCandidateFields.candidateType;
1662-
1663-
this.address = iceCandidateFields.connectionAddress;
1664-
this.ip = iceCandidateFields.connectionAddress;
1665-
this.protocol = iceCandidateFields.transport;
1666-
this.port = iceCandidateFields.port;
1667-
1668-
this.relatedAddress = iceCandidateFields.remoteConnectionAddress || null;
1669-
this.relatedPort = iceCandidateFields.remotePort || null;
1658+
if (iceCandidateFields) {
1659+
this.foundation = iceCandidateFields.foundation;
1660+
this.component = iceCandidateFields.componentId;
1661+
this.priority = iceCandidateFields.priority;
1662+
this.type = iceCandidateFields.candidateType;
1663+
1664+
this.address = iceCandidateFields.connectionAddress;
1665+
this.ip = iceCandidateFields.connectionAddress;
1666+
this.protocol = iceCandidateFields.transport;
1667+
this.port = iceCandidateFields.port;
1668+
1669+
this.relatedAddress = iceCandidateFields.remoteConnectionAddress || null;
1670+
this.relatedPort = iceCandidateFields.remotePort || null;
1671+
}
16701672
}
16711673
},{}],10:[function(_dereq_,module,exports){
16721674
(function (global){

js/RTCIceCandidate.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,18 @@ function RTCIceCandidate(data) {
171171
// Parse candidate SDP:
172172
// Example: candidate:1829696681 1 udp 2122262783 2a01:cb05:8d3e:a300:e1ad:79c1:7096:8ba0 49778 typ host generation 0 ufrag c9L6 network-id 2 network-cost 10
173173
var iceCandidateFields = candidateToJson(this.candidate);
174-
this.foundation = iceCandidateFields.foundation;
175-
this.component = iceCandidateFields.componentId;
176-
this.priority = iceCandidateFields.priority;
177-
this.type = iceCandidateFields.candidateType;
178-
179-
this.address = iceCandidateFields.connectionAddress;
180-
this.ip = iceCandidateFields.connectionAddress;
181-
this.protocol = iceCandidateFields.transport;
182-
this.port = iceCandidateFields.port;
183-
184-
this.relatedAddress = iceCandidateFields.remoteConnectionAddress || null;
185-
this.relatedPort = iceCandidateFields.remotePort || null;
174+
if (iceCandidateFields) {
175+
this.foundation = iceCandidateFields.foundation;
176+
this.component = iceCandidateFields.componentId;
177+
this.priority = iceCandidateFields.priority;
178+
this.type = iceCandidateFields.candidateType;
179+
180+
this.address = iceCandidateFields.connectionAddress;
181+
this.ip = iceCandidateFields.connectionAddress;
182+
this.protocol = iceCandidateFields.transport;
183+
this.port = iceCandidateFields.port;
184+
185+
this.relatedAddress = iceCandidateFields.remoteConnectionAddress || null;
186+
this.relatedPort = iceCandidateFields.remotePort || null;
187+
}
186188
}

0 commit comments

Comments
 (0)