diff options
| author | Neil <nyamatongwe@gmail.com> | 2021-03-29 09:03:04 +1100 | 
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2021-03-29 09:03:04 +1100 | 
| commit | f1ad63380ea954ae42c26d0a4fc0e46574cd9e5f (patch) | |
| tree | d0b95dd1e509cc0eca7a353520e9c409c0497195 /gtk/PlatGTK.cxx | |
| parent | ab70e1041cb40c9d807a18ca7abb5c000adf2fdf (diff) | |
| download | scintilla-mirror-f1ad63380ea954ae42c26d0a4fc0e46574cd9e5f.tar.gz | |
Modify ListBox::GetValue to return a std::string to avoid fixed size buffers
and the possibility of truncation.
Diffstat (limited to 'gtk/PlatGTK.cxx')
| -rwxr-xr-x | gtk/PlatGTK.cxx | 12 | 
1 files changed, 6 insertions, 6 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index a6ced568a..c71d1dff4 100755 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -1394,7 +1394,7 @@ public:  	void Select(int n) override;  	int GetSelection() override;  	int Find(const char *prefix) override; -	void GetValue(int n, char *value, int len) override; +	std::string GetValue(int n) override;  	void RegisterRGBA(int type, std::unique_ptr<RGBAImage> image);  	void RegisterImage(int type, const char *xpm_data) override;  	void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) override; @@ -1961,7 +1961,7 @@ int ListBoxX::Find(const char *prefix) {  	return -1;  } -void ListBoxX::GetValue(int n, char *value, int len) { +std::string ListBoxX::GetValue(int n) {  	char *text = nullptr;  	GtkTreeIter iter {};  	GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(list)); @@ -1969,12 +1969,12 @@ void ListBoxX::GetValue(int n, char *value, int len) {  	if (valid) {  		gtk_tree_model_get(model, &iter, TEXT_COLUMN, &text, -1);  	} -	if (text && len > 0) { -		g_strlcpy(value, text, len); -	} else { -		value[0] = '\0'; +	std::string value; +	if (text) { +		value = text;  	}  	g_free(text); +	return value;  }  // g_return_if_fail causes unnecessary compiler warning in release compile.  | 
