aboutsummaryrefslogtreecommitdiffstats
path: root/sway/ipc-json.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2016-12-15 18:26:53 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2016-12-15 19:01:41 -0500
commit10c8b73075fa0dd5512cc14be7240ec47f68dece (patch)
treee8835ef640d1d21ce0f36a5b1bcee726d926e55e /sway/ipc-json.c
parentAdd remaining sway allocation failure handling (diff)
downloadsway-10c8b73075fa0dd5512cc14be7240ec47f68dece.tar.gz
sway-10c8b73075fa0dd5512cc14be7240ec47f68dece.tar.zst
sway-10c8b73075fa0dd5512cc14be7240ec47f68dece.zip
Handle calloc failures
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r--sway/ipc-json.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index e65e9de3..fd17216e 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -245,6 +245,15 @@ json_object *ipc_json_get_version() {
245 245
246#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE 246#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE
247 char *full_version = calloc(strlen(SWAY_GIT_VERSION) + strlen(SWAY_GIT_BRANCH) + strlen(SWAY_VERSION_DATE) + 20, 1); 247 char *full_version = calloc(strlen(SWAY_GIT_VERSION) + strlen(SWAY_GIT_BRANCH) + strlen(SWAY_VERSION_DATE) + 20, 1);
248 if (!full_version) {
249 json_object_object_add(version, "human_readable",
250 json_object_new_string("Allocating version string failed"));
251 // TODO: it's stupid that we allocate this in the first place
252 json_object_object_add(version, "major", json_object_new_int(0));
253 json_object_object_add(version, "minor", json_object_new_int(0));
254 json_object_object_add(version, "patch", json_object_new_int(0));
255 return version;
256 }
248 strcat(full_version, SWAY_GIT_VERSION); 257 strcat(full_version, SWAY_GIT_VERSION);
249 strcat(full_version, " ("); 258 strcat(full_version, " (");
250 strcat(full_version, SWAY_VERSION_DATE); 259 strcat(full_version, SWAY_VERSION_DATE);