Missing NULL checks - qmi-proxy.c

Peter Naulls peter at chocky.org
Mon Dec 21 12:41:03 UTC 2020


Here are some trivial null checks I found during testing.  I believe there are 
some more issues remaining.  This is against both latest release 1.2.26.6 and 
current git.

--- a/src/libqmi-glib/qmi-proxy.c	2020-12-17 20:07:45.620241110 -0500
+++ b/src/libqmi-glib/qmi-proxy.c	2020-12-17 20:21:32.405975476 -0500
@@ -212,7 +212,7 @@
  {
      guint i;

-    if (!client->qmi_client_info_array->len)
+    if (!client->qmi_client_info_array || !client->qmi_client_info_array->len)
          return;

      for (i = 0; i < client->qmi_client_info_array->len; i++) {
@@ -311,6 +311,8 @@
  {
      guint i;

+    if (!client->qmi_client_info_array) return;
+
      for (i = 0; i < client->qmi_client_info_array->len; i++) {
          QmiClientInfo *info;

@@ -541,6 +543,8 @@
  {
      guint i;

+    if (!array) return -1;
+
      for (i = 0; i < array->len; i++) {
          QmiClientInfo *item;



More information about the libqmi-devel mailing list