From 0a5a65cf4819ebffb74c410735ba676b288bb82d Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Mon, 14 Feb 2022 15:27:34 +0100 Subject: 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. --- examples/input-method.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'examples') 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++; -- cgit v1.2.3