diff --git a/src/friendlist.c b/src/friendlist.c index f3f6352..e070575 100644 --- a/src/friendlist.c +++ b/src/friendlist.c @@ -716,7 +716,7 @@ static void delete_blocked_friend(uint32_t bnum); /* deactivates delete friend popup and deletes friend if instructed */ static void del_friend_deactivate(Tox *m, wint_t key) { - if (key == 'y') { + if (key == L'y') { if (blocklist_view == 0) { delete_friend(m, PendingDelete.num); sort_friendlist_index(); diff --git a/src/term_mplex.c b/src/term_mplex.c index 0dbe4ee..0c0591d 100644 --- a/src/term_mplex.c +++ b/src/term_mplex.c @@ -153,7 +153,12 @@ static char *extract_socket_path(const char *info) return NULL; } - path = (char *) malloc(end - pos + 1); + path = malloc(end - pos + 1); + + if (path == NULL) { + return NULL; + } + *end = '\0'; return strcpy(path, pos); } @@ -310,7 +315,12 @@ static int tmux_is_detached(void) session_info_stream = NULL; /* prepare search string, for finding the current session's entry */ - search_str = (char *) malloc(numstr_len + 2); + search_str = malloc(numstr_len + 2); + + if (search_str == NULL) { + goto fail; + } + search_str[0] = '\n'; strcpy(search_str + 1, mplex_data); diff --git a/src/toxic.c b/src/toxic.c index 38d732b..9f1dd04 100644 --- a/src/toxic.c +++ b/src/toxic.c @@ -429,12 +429,17 @@ static int password_prompt(char *buf, int size) } const char *p = fgets(buf, size, stdin); - int len = strlen(buf); /* re-enable terminal echo */ tcsetattr(fileno(stdin), TCSANOW, &oflags); - if (p == NULL || len <= 1) { + if (p == NULL) { + return 0; + } + + size_t len = strlen(buf); + + if (len <= 1) { return 0; }