]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/cpuset: Skip optarg duplication
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 11 Apr 2026 18:38:02 +0000 (20:38 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 12 Apr 2026 11:08:32 +0000 (13:08 +0200)
Fix potential memory leaks and clarify that content of these strings
is never modified. Won't happen since this is test code, but adjust it
for completeness.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
lib/cpuset.c

index b04c71a355aea353f669d347211f8de56c105ad8..c5679888ed57a7e9188ff9df857823ba8c6d7de8 100644 (file)
@@ -395,10 +395,10 @@ int main(int argc, char *argv[])
                        ncpus = atoi(optarg);
                        break;
                case 'm':
-                       mask = strdup(optarg);
+                       mask = optarg;
                        break;
                case 'r':
-                       range = strdup(optarg);
+                       range = optarg;
                        break;
                default:
                        goto usage_err;
@@ -435,8 +435,6 @@ int main(int argc, char *argv[])
        printf("[%s]\n", cpulist_create(buf, buflen, set, setsize));
 
        free(buf);
-       free(mask);
-       free(range);
        cpuset_free(set);
 
        return EXIT_SUCCESS;