diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-06-02 02:43:58 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-06-02 02:43:58 -0700 |
commit | 823b81363a1145de4b8660153007b11faf4e2c56 (patch) | |
tree | 09d9c70e232c1b98ec8447cae6b6618bcd91497d /web/web_prompt.c | |
parent | 1db534799ef5b41114d80fce0c38f1c93235a8a3 (diff) | |
download | dartboat-823b81363a1145de4b8660153007b11faf4e2c56.tar.gz dartboat-823b81363a1145de4b8660153007b11faf4e2c56.tar.xz |
web: fix minor mem leaks and bugs
Diffstat (limited to 'web/web_prompt.c')
-rw-r--r-- | web/web_prompt.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/web/web_prompt.c b/web/web_prompt.c index 37745e8..9fefa7a 100644 --- a/web/web_prompt.c +++ b/web/web_prompt.c @@ -486,9 +486,14 @@ static void prompt_handle_on_change() if (pm != PM_VISIT) return; + int pts = 0; char *str = prompt_get(); - update_user_rem_from_pts(atoi(str)); - free(str); + if (str) { + pts = atoi(str); + free(str); + } + + update_user_rem_from_pts(pts); } static void prompt_handle_append(char *data) @@ -499,7 +504,7 @@ static void prompt_handle_append(char *data) return; char *str = prompt_get(); - size_t len_str = strlen(str); + size_t len_str = str ? strlen(str) : 0; size_t len_data = strlen(data); if (len_str < 3) { str = realloc(str, len_str + len_data + 1); @@ -516,6 +521,8 @@ static void prompt_handle_backspace() return; char *str = prompt_get(); + if (!str) + return; size_t len_str = strlen(str); if (len_str > 0) { str[len_str-1] = 0; @@ -549,6 +556,8 @@ static void prompt_handle_submit() return; char *str = prompt_get(); + if (!str) + return; prompt_handle_clear(); if (*str) { if (pm == PM_VISIT) @@ -575,6 +584,8 @@ static void prompt_handle_rem() return; char *str = prompt_get(); + if (!str) + return; prompt_handle_clear(); if (*str) user_visit_to_rem(atoi(str)); |