]> git.mdlowis.com Git - proto/labwc.git/commitdiff
rcxml: add missing check for calibrationMatrix
authorSnowNF <SnowNF@outlook.com>
Thu, 21 Mar 2024 08:46:44 +0000 (16:46 +0800)
committerJohan Malm <johanmalm@users.noreply.github.com>
Thu, 21 Mar 2024 22:07:33 +0000 (22:07 +0000)
src/config/rcxml.c

index 58ebc87247efc456e1b18e3bd6edc61c0b4a24e8..994498c3f2d7225ae3c06a598465ac1c342419c7 100644 (file)
@@ -617,7 +617,8 @@ fill_libinput_category(char *nodename, char *content)
                current_libinput_category->have_calibration_matrix = true;
                float *mat = current_libinput_category->calibration_matrix;
                gchar **elements = g_strsplit(content, " ", -1);
-               for (guint i = 0; elements[i]; ++i) {
+               guint i = 0;
+               for (; elements[i]; ++i) {
                        char *end_str = NULL;
                        mat[i] = strtof(elements[i], &end_str);
                        if (errno == ERANGE || *end_str != '\0' || i == 6 || *elements[i] == '\0') {
@@ -629,6 +630,11 @@ fill_libinput_category(char *nodename, char *content)
                                break;
                        }
                }
+               if (i != 6 && current_libinput_category->have_calibration_matrix) {
+                       wlr_log(WLR_ERROR, "wrong number of calibration matrix elements,"
+                                                               " expected 6, got %d", i);
+                       current_libinput_category->have_calibration_matrix = false;
+               }
                g_strfreev(elements);
        }
 }