diff options
author | Alan Coopersmith <Alan.Coopersmith@sun.com> | 2006-03-10 01:32:05 +0000 |
---|---|---|
committer | Alan Coopersmith <Alan.Coopersmith@sun.com> | 2006-03-10 01:32:05 +0000 |
commit | 13f2d5790eb194ab721f0df4e6f3cdf800c0e773 (patch) | |
tree | fca0bb4addb121f6613679cd81d9f0d385d7b69b | |
parent | 73fbe5dacc9969cbb8495fbd7691ae267d482656 (diff) |
Replace custom copystring() with standard strdup() (Also should clearXORG-7_0_99_901
Coverity warning #6827 against copystring)
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | xrefresh.c | 25 |
2 files changed, 14 insertions, 17 deletions
@@ -1,3 +1,9 @@ +2006-03-09 Alan Coopersmith <alan.coopersmith@sun.com> + + * xrefresh.c: + Replace custom copystring() with standard strdup() + (Also should clear Coverity warning #6827 against copystring) + 2005-12-20 Kevin E. Martin <kem-at-freedesktop-dot-org> * configure.ac: @@ -1,3 +1,4 @@ +/* $XdotOrg: $ */ /*********************************************************** Copyright 1987, 1988, 1998 The Open Group @@ -82,22 +83,6 @@ Syntax(void) exit (1); } -static char * -copystring(char *s) -{ - int len = (s ? strlen (s) : 0) + 1; - char *retval; - - retval = malloc (len); - if (!retval) { - fprintf (stderr, "%s: unable to allocate %d bytes for string.\n", - ProgramName, len); - exit (1); - } - (void) strcpy (retval, s); - return (retval); -} - /* * The following parses options that should be yes or no; it returns -1, 0, 1 * for error, no, yes. @@ -235,7 +220,13 @@ main(int argc, char *argv[]) char *def; if ((def = XGetDefault (dpy, ProgramName, "Solid")) != NULL) { - solidcolor = copystring (def); + solidcolor = strdup (def); + if (solidcolor == NULL) { + fprintf (stderr, + "%s: unable to allocate memory for string.\n", + ProgramName); + exit (1); + } action = doSolid; } else { struct s_pair *pp; |