summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/sed.c5
-rw-r--r--sed.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 115783f..770a56e 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -309,7 +309,10 @@ static void parse_edit_cmd(struct sed_cmd *sed_cmd, const char *editstr)
fatalError("bad format in edit expression\n");
/* store the edit line text */
- sed_cmd->editline = strdup(&editstr[3]);
+ /* make editline big enough to accomodate the extra '\n' we will tack on
+ * to the end */
+ sed_cmd->editline = xmalloc(strlen(&editstr[3]) + 2);
+ strcpy(sed_cmd->editline, &editstr[3]);
ptr = sed_cmd->editline;
/* now we need to go through * and: s/\\[\r\n]$/\n/g on the edit line */
diff --git a/sed.c b/sed.c
index 115783f..770a56e 100644
--- a/sed.c
+++ b/sed.c
@@ -309,7 +309,10 @@ static void parse_edit_cmd(struct sed_cmd *sed_cmd, const char *editstr)
fatalError("bad format in edit expression\n");
/* store the edit line text */
- sed_cmd->editline = strdup(&editstr[3]);
+ /* make editline big enough to accomodate the extra '\n' we will tack on
+ * to the end */
+ sed_cmd->editline = xmalloc(strlen(&editstr[3]) + 2);
+ strcpy(sed_cmd->editline, &editstr[3]);
ptr = sed_cmd->editline;
/* now we need to go through * and: s/\\[\r\n]$/\n/g on the edit line */