mirror of
https://github.com/swaywm/sway.git
synced 2025-11-03 09:01:43 -05:00
Handle calloc failures
This commit is contained in:
parent
a2b9149656
commit
10c8b73075
8 changed files with 39 additions and 2 deletions
|
|
@ -245,6 +245,15 @@ json_object *ipc_json_get_version() {
|
|||
|
||||
#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE
|
||||
char *full_version = calloc(strlen(SWAY_GIT_VERSION) + strlen(SWAY_GIT_BRANCH) + strlen(SWAY_VERSION_DATE) + 20, 1);
|
||||
if (!full_version) {
|
||||
json_object_object_add(version, "human_readable",
|
||||
json_object_new_string("Allocating version string failed"));
|
||||
// TODO: it's stupid that we allocate this in the first place
|
||||
json_object_object_add(version, "major", json_object_new_int(0));
|
||||
json_object_object_add(version, "minor", json_object_new_int(0));
|
||||
json_object_object_add(version, "patch", json_object_new_int(0));
|
||||
return version;
|
||||
}
|
||||
strcat(full_version, SWAY_GIT_VERSION);
|
||||
strcat(full_version, " (");
|
||||
strcat(full_version, SWAY_VERSION_DATE);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue