aboutsummaryrefslogtreecommitdiff
path: root/plugins/omemo/src/bundle.vala
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2017-04-18 17:55:20 +0200
committerMarvin W <git@larma.de>2017-04-18 20:20:41 +0200
commit7e388fb2bc784568734592dcb2e863dfa061bed4 (patch)
treeeb4fb804fd7cf9df02b39d37b61937f355785810 /plugins/omemo/src/bundle.vala
parentf95b4f4e0949eefaed871c267626e3ff84ce5ca6 (diff)
downloaddino-7e388fb2bc784568734592dcb2e863dfa061bed4.tar.gz
dino-7e388fb2bc784568734592dcb2e863dfa061bed4.zip
signal-protocol/omemo: fix null-pointer issues
Fixes #44 and #58
Diffstat (limited to 'plugins/omemo/src/bundle.vala')
-rw-r--r--plugins/omemo/src/bundle.vala25
1 files changed, 13 insertions, 12 deletions
diff --git a/plugins/omemo/src/bundle.vala b/plugins/omemo/src/bundle.vala
index 211dc29b..688f6192 100644
--- a/plugins/omemo/src/bundle.vala
+++ b/plugins/omemo/src/bundle.vala
@@ -9,21 +9,22 @@ public class Bundle {
public Bundle(StanzaNode? node) {
this.node = node;
+ assert(Plugin.ensure_context());
}
public int32 signed_pre_key_id { owned get {
if (node == null) return -1;
- string id = node.get_deep_attribute("signedPreKeyPublic", "signedPreKeyId");
+ string? id = ((!)node).get_deep_attribute("signedPreKeyPublic", "signedPreKeyId");
if (id == null) return -1;
- return int.parse(id);
+ return int.parse((!)id);
}}
public ECPublicKey? signed_pre_key { owned get {
if (node == null) return null;
- string? key = node.get_deep_string_content("signedPreKeyPublic");
+ string? key = ((!)node).get_deep_string_content("signedPreKeyPublic");
if (key == null) return null;
try {
- return Plugin.context.decode_public_key(Base64.decode(key));
+ return Plugin.get_context().decode_public_key(Base64.decode((!)key));
} catch (Error e) {
return null;
}
@@ -31,17 +32,17 @@ public class Bundle {
public uint8[]? signed_pre_key_signature { owned get {
if (node == null) return null;
- string? sig = node.get_deep_string_content("signedPreKeySignature");
+ string? sig = ((!)node).get_deep_string_content("signedPreKeySignature");
if (sig == null) return null;
- return Base64.decode(sig);
+ return Base64.decode((!)sig);
}}
public ECPublicKey? identity_key { owned get {
if (node == null) return null;
- string? key = node.get_deep_string_content("identityKey");
+ string? key = ((!)node).get_deep_string_content("identityKey");
if (key == null) return null;
try {
- return Plugin.context.decode_public_key(Base64.decode(key));
+ return Plugin.get_context().decode_public_key(Base64.decode((!)key));
} catch (Error e) {
return null;
}
@@ -49,9 +50,9 @@ public class Bundle {
public ArrayList<PreKey> pre_keys { owned get {
ArrayList<PreKey> list = new ArrayList<PreKey>();
- if (node == null || node.get_subnode("prekeys") == null) return list;
- node.get_deep_subnodes("prekeys", "preKeyPublic")
- .filter((node) => node.get_attribute("preKeyId") != null)
+ if (node == null || ((!)node).get_subnode("prekeys") == null) return list;
+ ((!)node).get_deep_subnodes("prekeys", "preKeyPublic")
+ .filter((node) => ((!)node).get_attribute("preKeyId") != null)
.map<PreKey>(PreKey.create)
.foreach((key) => list.add(key));
return list;
@@ -76,7 +77,7 @@ public class Bundle {
string? key = node.get_string_content();
if (key == null) return null;
try {
- return Plugin.context.decode_public_key(Base64.decode(key));
+ return Plugin.get_context().decode_public_key(Base64.decode((!)key));
} catch (Error e) {
return null;
}