Merge "audio-HAL: Fix for KW static analysis issues"
diff --git a/hal/audio_extn/spkr_protection.c b/hal/audio_extn/spkr_protection.c
index 571b4f3..c7f5726 100644
--- a/hal/audio_extn/spkr_protection.c
+++ b/hal/audio_extn/spkr_protection.c
@@ -30,7 +30,7 @@
 /*
 * Changes from Qualcomm Innovation Center are provided under the following license:
 *
-* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted (subject to the limitations in the
@@ -1370,8 +1370,10 @@
                         }
                        thermal_fd = open(wsa_path, O_RDONLY);
                        if (thermal_fd > 0) {
-                           if ((ret = read(thermal_fd, buf, sizeof(buf))) >= 0)
+                           if ((ret = read(thermal_fd, buf, sizeof(buf))) >= 0) {
+                               buf[ret-1] = '\0';
                                t0_spk_1 = atoi(buf);
+                           }
                            else
                                ALOGE("%s: read fail for %s err:%d\n",
                                      __func__, wsa_path, ret);
@@ -1404,8 +1406,10 @@
                         }
                         thermal_fd = open(wsa_path, O_RDONLY);
                         if (thermal_fd > 0) {
-                           if ((ret = read(thermal_fd, buf, sizeof(buf))) >= 0)
+                           if ((ret = read(thermal_fd, buf, sizeof(buf))) >= 0) {
+                               buf[ret-1] = '\0';
                                t0_spk_2 = atoi(buf);
+                           }
                            else
                                ALOGE("%s: read fail for %s err:%d\n",
                                      __func__, wsa_path, ret);