diff options
author | Guido Günther <agx@sigxcpu.org> | 2022-02-14 15:27:34 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-03-02 14:28:58 +0000 |
commit | 0a5a65cf4819ebffb74c410735ba676b288bb82d (patch) | |
tree | d67d27e884273dc23b672b7f651c629be8239cf1 | |
parent | 4741e9d8410fd66445b45500cb3589f52c5de36b (diff) |
examples/input-method: Don't crash on NULL surrounding text
E.g. With e.g. gnome-terminal we never end up in handle_surrouding
so it will be NULL.
-rw-r--r-- | examples/input-method.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/input-method.c b/examples/input-method.c index 479c8761..849971b9 100644 --- a/examples/input-method.c +++ b/examples/input-method.c @@ -194,7 +194,7 @@ static void do_updates(void) { update_stage++; break; case 2: - if (strcmp(current.surrounding.text, "_Commit_") != 0) { + if (current.surrounding.text && strcmp(current.surrounding.text, "_Commit_") != 0) { return; } zwp_input_method_v2_commit_string(input_method, "_CommitNoPreed_"); @@ -203,7 +203,7 @@ static void do_updates(void) { update_stage++; break; case 3: - if (strcmp(current.surrounding.text, "_Commit__CommitNoPreed_") != 0) { + if (current.surrounding.text && strcmp(current.surrounding.text, "_Commit__CommitNoPreed_") != 0) { return; } zwp_input_method_v2_commit_string(input_method, "_WaitNo_"); @@ -212,7 +212,7 @@ static void do_updates(void) { update_stage++; break; case 4: - if (strcmp(current.surrounding.text, "_Commit__WaitNo_") != 0) { + if (current.surrounding.text && strcmp(current.surrounding.text, "_Commit__WaitNo_") != 0) { return; } zwp_input_method_v2_set_preedit_string(input_method, "PreedWithDel", strlen("Preed"), strlen("Preed")); @@ -221,7 +221,7 @@ static void do_updates(void) { update_stage++; break; case 5: - if (strcmp(current.surrounding.text, "_Commit_") != 0) { + if (current.surrounding.text && strcmp(current.surrounding.text, "_Commit_") != 0) { return; } zwp_input_method_v2_delete_surrounding_text(input_method, strlen("mit_"), 0); @@ -229,7 +229,7 @@ static void do_updates(void) { update_stage++; break; case 6: - if (strcmp(current.surrounding.text, "_Com") != 0) { + if (current.surrounding.text && strcmp(current.surrounding.text, "_Com") != 0) { printf("Failed\n"); } update_stage++; |