Remove useless pg_strdup() operations.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 4 Sep 2016 16:33:58 +0000 (12:33 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 4 Sep 2016 16:33:58 +0000 (12:33 -0400)
split_to_stringlist() doesn't modify its first argument nor expect it
to remain valid after exit, so there's no need to duplicate the optarg
string at the call sites.  Per Coverity.  (This has been wrong all along,
but commit 052cc223d changed the useless calls from "strdup" to
"pg_strdup", which apparently made Coverity think it's a new bug.
It's not, but it's also not worth back-patching.)

src/test/regress/pg_regress.c

index 226005784004e01a9bc4ebae7a9ac3ec18471bb1..14c87c91abdb37b8a68de7621a8bde035dd5a732 100644 (file)
@@ -2064,7 +2064,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
                                 * before we add the specified one.
                                 */
                                free_stringlist(&dblist);
-                               split_to_stringlist(pg_strdup(optarg), ", ", &dblist);
+                               split_to_stringlist(optarg, ", ", &dblist);
                                break;
                        case 2:
                                debug = true;
@@ -2114,7 +2114,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
                                dlpath = pg_strdup(optarg);
                                break;
                        case 18:
-                               split_to_stringlist(pg_strdup(optarg), ", ", &extraroles);
+                               split_to_stringlist(optarg, ", ", &extraroles);
                                break;
                        case 19:
                                add_stringlist_item(&temp_configs, optarg);