diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-12-15 17:05:12 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-12-15 19:01:40 -0500 |
commit | 9ad1e6b40f9589a5ab8242dd3b2e514b70d97799 (patch) | |
tree | 2e80e1258f5e1af0465a7dfd9959397f7009e6df /common/log.c | |
parent | Merge pull request #991 from barfoo1/registry_fix (diff) | |
download | sway-9ad1e6b40f9589a5ab8242dd3b2e514b70d97799.tar.gz sway-9ad1e6b40f9589a5ab8242dd3b2e514b70d97799.tar.zst sway-9ad1e6b40f9589a5ab8242dd3b2e514b70d97799.zip |
Handle malloc failure in ipc_recv_response
Diffstat (limited to 'common/log.c')
-rw-r--r-- | common/log.c | 11 |
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 | |||
88 | } | 88 | } |
89 | 89 | ||
90 | if (filename && line) { | 90 | if (filename && line) { |
91 | char *file = strdup(filename); | 91 | const char *file = filename + strlen(filename); |
92 | fprintf(stderr, "[%s:%d] ", basename(file), line); | 92 | while (file != filename && *file != '/') { |
93 | free(file); | 93 | --file; |
94 | } | ||
95 | if (*file == '/') { | ||
96 | ++file; | ||
97 | } | ||
98 | fprintf(stderr, "[%s:%d] ", file, line); | ||
94 | } | 99 | } |
95 | 100 | ||
96 | va_list args; | 101 | va_list args; |