summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <Alan.Coopersmith@sun.com>2006-03-10 01:32:05 +0000
committerAlan Coopersmith <Alan.Coopersmith@sun.com>2006-03-10 01:32:05 +0000
commit13f2d5790eb194ab721f0df4e6f3cdf800c0e773 (patch)
treefca0bb4addb121f6613679cd81d9f0d385d7b69b
parent73fbe5dacc9969cbb8495fbd7691ae267d482656 (diff)
Replace custom copystring() with standard strdup() (Also should clearXORG-7_0_99_901
Coverity warning #6827 against copystring)
-rw-r--r--ChangeLog6
-rw-r--r--xrefresh.c25
2 files changed, 14 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 6eb4c51..787cf25 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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:
diff --git a/xrefresh.c b/xrefresh.c
index ae8b7c3..b9f6c99 100644
--- a/xrefresh.c
+++ b/xrefresh.c
@@ -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;