diff options
| author | Isaac Freund <mail@isaacfreund.com> | 2021-11-07 20:34:24 +0100 | 
|---|---|---|
| committer | Isaac Freund <mail@isaacfreund.com> | 2021-11-07 21:01:24 +0100 | 
| commit | e326b76959a4dfa1f41ba9548a81aac5df7730de (patch) | |
| tree | bb2b689feae873c6bd7a70a1f78de8110b0f3fac | |
| parent | eb5f23d6d028281687d7fa63e82624dcf0e7a734 (diff) | |
| download | wlroots-e326b76959a4dfa1f41ba9548a81aac5df7730de.tar.xz | |
text-input/input-method: handle strdup() failure
| -rw-r--r-- | types/wlr_input_method_v2.c | 8 | ||||
| -rw-r--r-- | types/wlr_text_input_v3.c | 4 | 
2 files changed, 12 insertions, 0 deletions
| diff --git a/types/wlr_input_method_v2.c b/types/wlr_input_method_v2.c index 6ad2615f..7ccd31ee 100644 --- a/types/wlr_input_method_v2.c +++ b/types/wlr_input_method_v2.c @@ -88,6 +88,10 @@ static void im_commit_string(struct wl_client *client,  	}  	free(input_method->pending.commit_text);  	input_method->pending.commit_text = strdup(text); +	if (input_method->pending.commit_text == NULL) { +		wl_client_post_no_memory(client); +		return; +	}  }  static void im_set_preedit_string(struct wl_client *client, @@ -102,6 +106,10 @@ static void im_set_preedit_string(struct wl_client *client,  	input_method->pending.preedit.cursor_end = cursor_end;  	free(input_method->pending.preedit.text);  	input_method->pending.preedit.text = strdup(text); +	if (input_method->pending.preedit.text == NULL) { +		wl_client_post_no_memory(client); +		return; +	}  }  static void im_delete_surrounding_text(struct wl_client *client, diff --git a/types/wlr_text_input_v3.c b/types/wlr_text_input_v3.c index c6e43ec2..9a4c42c9 100644 --- a/types/wlr_text_input_v3.c +++ b/types/wlr_text_input_v3.c @@ -171,6 +171,10 @@ static void text_input_commit(struct wl_client *client,  	if (text_input->pending.surrounding.text) {  		text_input->current.surrounding.text =  			strdup(text_input->pending.surrounding.text); +		if (text_input->current.surrounding.text == NULL) { +			wl_client_post_no_memory(client); +			return; +		}  	}  	bool old_enabled = text_input->current_enabled; | 
