aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os/log.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-12-12 20:34:06 +0000
committermarha <marha@users.sourceforge.net>2010-12-12 20:34:06 +0000
commitd3ae6e21a12209f5c8cb8c84ba0f68fb69736844 (patch)
tree62710b8524ebc7675ebd7f4976fd7f9530ce5df2 /xorg-server/os/log.c
parent0be679f7724e33c2761ebb67846707fb3351167b (diff)
parent3a20d23b48c1051e1f22295fd886cc7f643417f6 (diff)
downloadvcxsrv-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.c12
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",