]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
target/xtensa: Replace malloc() with g_strdup_printf()
authorDmitry Frolov <frolov@swemel.ru>
Wed, 30 Jul 2025 06:21:43 +0000 (09:21 +0300)
committerThomas Huth <thuth@redhat.com>
Mon, 27 Apr 2026 07:11:36 +0000 (09:11 +0200)
malloc() return value is used without a check.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Message-ID: <20250730062142.1665980-1-frolov@swemel.ru>
Signed-off-by: Thomas Huth <thuth@redhat.com>
target/xtensa/translate.c

index 6f9dd9fb5cfb62388598bf01d79a0f5b80aebee7..175fd4b5cfc2d7d245da8faf397d58583cf647c5 100644 (file)
@@ -112,17 +112,12 @@ void xtensa_collect_sr_names(const XtensaConfig *config)
 
             if (*pname) {
                 if (strstr(*pname, name) == NULL) {
-                    char *new_name =
-                        malloc(strlen(*pname) + strlen(name) + 2);
-
-                    strcpy(new_name, *pname);
-                    strcat(new_name, "/");
-                    strcat(new_name, name);
-                    free(*pname);
+                    char *new_name = g_strdup_printf("%s/%s", *pname, name);
+                    g_free(*pname);
                     *pname = new_name;
                 }
             } else {
-                *pname = strdup(name);
+                *pname = g_strdup(name);
             }
         }
     }