summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;