diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-11-11 20:40:18 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-11-16 22:58:38 -0800 |
commit | 66c09c83aa2f64b31dc657f90447c269621545b7 (patch) | |
tree | 211b6c3ea96175770e25a62a1220d898f4a9e0c7 /pf.c | |
parent | 8751095511c7d9065ab12a40e90e38bdd9d728e4 (diff) |
Fix gcc -Wwrite-strings warnings
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Diffstat (limited to 'pf.c')
-rw-r--r-- | pf.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -78,17 +78,19 @@ void process_file (const char *filename) /* NULL means use stdin */ } -void process_line (char *buffer) +void process_line (const char *line) { int len; int i; - char *cp; - - /* copy buffer since it may point to unwritable date */ - len = strlen(buffer); - cp = chk_malloc(len + 1); - strcpy(cp, buffer); - buffer = cp; + char *cp, *buffer; + + /* copy line to buffer since it may point to unwritable data */ + len = strlen(line); + cp = buffer = strdup(line); + if (buffer == NULL) { + fprintf(stderr, "%s: Could not allocate %d bytes\n", ProgramName, len); + Exit(-1); + } for (i = 0; i < len; i++) { /* look for blank lines */ register char c = buffer[i]; |