Allocate fresh memory for post_opts/exec_path
authorStephen Frost <sfrost@snowman.net>
Wed, 5 Mar 2014 13:50:12 +0000 (08:50 -0500)
committerStephen Frost <sfrost@snowman.net>
Wed, 5 Mar 2014 13:50:12 +0000 (08:50 -0500)
Instead of having read_post_opts() depend on the memory allocated for
the config file (which is now getting free'd), pg_strdup() for
post_opts and exec_path (similar to how it's being done elsewhere).

Noted by Thom Brown.

src/bin/pg_ctl/pg_ctl.c

index ff84498a005e828ed51fc2c1d8fedf02cfc3026b..0dbaa6e27fe5009d7f0e95710309bc7056779c61 100644 (file)
@@ -730,10 +730,10 @@ read_post_opts(void)
                {
                    *arg1 = '\0';       /* terminate so we get only program
                                         * name */
-                   post_opts = arg1 + 1;       /* point past whitespace */
+                   post_opts = pg_strdup(arg1 + 1); /* point past whitespace */
                }
                if (exec_path == NULL)
-                   exec_path = optline;
+                   exec_path = pg_strdup(optline);
            }
 
            /* Free the results of readfile. */