[PATCH v2] libmm-glib,sms-properties: fix potential NULL dereference

Ben Chan benchan at chromium.org
Fri Aug 11 21:16:47 UTC 2017


This patch fixes a potential NULL referenece issue in
mm_sms_properties_get_data() where it accesses `self->priv->data->data'
when `self->priv->data' could be potentially NULL.
---
 libmm-glib/mm-sms-properties.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libmm-glib/mm-sms-properties.c b/libmm-glib/mm-sms-properties.c
index da4aa804..b0ff5a3b 100644
--- a/libmm-glib/mm-sms-properties.c
+++ b/libmm-glib/mm-sms-properties.c
@@ -157,10 +157,10 @@ mm_sms_properties_get_data (MMSmsProperties *self,
 {
     g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), NULL);
 
-    if (self->priv->data && data_len)
-        *data_len = self->priv->data->len;
+    if (data_len)
+        *data_len = (self->priv->data ? self->priv->data->len : 0);
 
-    return self->priv->data->data;
+    return (self->priv->data ? self->priv->data->data : NULL);
 }
 
 /**
-- 
2.14.0.434.g98096fd7a8-goog



More information about the ModemManager-devel mailing list