diff options
author | marha <marha@users.sourceforge.net> | 2010-12-12 20:34:06 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2010-12-12 20:34:06 +0000 |
commit | d3ae6e21a12209f5c8cb8c84ba0f68fb69736844 (patch) | |
tree | 62710b8524ebc7675ebd7f4976fd7f9530ce5df2 /xorg-server/os/log.c | |
parent | 0be679f7724e33c2761ebb67846707fb3351167b (diff) | |
parent | 3a20d23b48c1051e1f22295fd886cc7f643417f6 (diff) | |
download | vcxsrv-d3ae6e21a12209f5c8cb8c84ba0f68fb69736844.tar.gz vcxsrv-d3ae6e21a12209f5c8cb8c84ba0f68fb69736844.tar.bz2 vcxsrv-d3ae6e21a12209f5c8cb8c84ba0f68fb69736844.zip |
svn merge ^/branches/released .
Diffstat (limited to 'xorg-server/os/log.c')
-rw-r--r-- | xorg-server/os/log.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/xorg-server/os/log.c b/xorg-server/os/log.c index ee231a31d..8d4dfc4ec 100644 --- a/xorg-server/os/log.c +++ b/xorg-server/os/log.c @@ -183,10 +183,8 @@ LogInit(const char *fname, const char *backup) char *logFileName = NULL;
if (fname && *fname) {
- logFileName = malloc(strlen(fname) + strlen(display) + 1);
- if (!logFileName)
+ if (asprintf(&logFileName, fname, display) == -1)
FatalError("Cannot allocate space for the log file name\n");
- sprintf(logFileName, fname, display);
if (backup && *backup) {
struct stat buf;
@@ -195,13 +193,9 @@ LogInit(const char *fname, const char *backup) char *suffix;
char *oldLog;
- oldLog = malloc(strlen(logFileName) + strlen(backup) +
- strlen(display) + 1);
- suffix = malloc(strlen(backup) + strlen(display) + 1);
- if (!oldLog || !suffix)
+ if ((asprintf(&suffix, backup, display) == -1) ||
+ (asprintf(&oldLog, "%s%s", logFileName, suffix) == -1))
FatalError("Cannot allocate space for the log file name\n");
- sprintf(suffix, backup, display);
- sprintf(oldLog, "%s%s", logFileName, suffix);
free(suffix);
if (rename(logFileName, oldLog) == -1) {
FatalError("Cannot move old log file \"%s\" to \"%s\"\n",
|