aboutsummaryrefslogtreecommitdiff
path: root/common/log.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2016-12-17 13:23:44 -0500
committerGitHub <noreply@github.com>2016-12-17 13:23:44 -0500
commitf04ee0e68d885d7e1101cc88f9a9337202041f1f (patch)
treefa4dc296a5f1377867752d320ceef4e4b0178bbf /common/log.c
parent6c0fc2093641868df28c4087902a040f7fae05d4 (diff)
parentd859f825d3612492678f5cd6cc6dc1f2647929e1 (diff)
downloadsway-f04ee0e68d885d7e1101cc88f9a9337202041f1f.tar.xz
Merge pull request #995 from SirCmpwn/memory-use
Handle allocation failures
Diffstat (limited to 'common/log.c')
-rw-r--r--common/log.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/common/log.c b/common/log.c
index 4f0baa3f..825b176b 100644
--- a/common/log.c
+++ b/common/log.c
@@ -88,9 +88,14 @@ void _sway_log(const char *filename, int line, log_importance_t verbosity, const
}
if (filename && line) {
- char *file = strdup(filename);
- fprintf(stderr, "[%s:%d] ", basename(file), line);
- free(file);
+ const char *file = filename + strlen(filename);
+ while (file != filename && *file != '/') {
+ --file;
+ }
+ if (*file == '/') {
+ ++file;
+ }
+ fprintf(stderr, "[%s:%d] ", file, line);
}
va_list args;