Add allocation for NULL-terminated selection ends.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1765 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
391765c193
commit
25e596bf0d
@ -1,3 +1,9 @@
|
||||
2007-07-30 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
||||
|
||||
* src/tools.c, src/sciwrappers.c, src/callbacks.c, src/search.c:
|
||||
Add allocation for NULL-terminated selection ends.
|
||||
|
||||
|
||||
2007-07-29 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
||||
|
||||
* scintilla/LexHTML.cxx, scintilla/Makefile.am:
|
||||
|
||||
@ -1902,7 +1902,9 @@ on_menu_open_selected_file1_activate (GtkMenuItem *menuitem,
|
||||
|
||||
if (sci_get_lines_selected(doc_list[idx].sci) == 1)
|
||||
{
|
||||
filename = g_malloc(sci_get_selected_text_length(doc_list[idx].sci));
|
||||
gint len = sci_get_selected_text_length(doc_list[idx].sci);
|
||||
|
||||
filename = g_malloc(len + 1);
|
||||
sci_get_selected_text(doc_list[idx].sci, filename);
|
||||
}
|
||||
else if (sci_get_lines_selected(doc_list[idx].sci) == 0)
|
||||
|
||||
@ -509,6 +509,8 @@ void sci_get_text(ScintillaObject* sci, gint len, gchar* text)
|
||||
}
|
||||
|
||||
|
||||
/* Text must be allocated sci_get_selected_text_length() + 1, because
|
||||
* the selection will be NULL-terminated. */
|
||||
void sci_get_selected_text(ScintillaObject* sci, gchar* text)
|
||||
{
|
||||
SSM( sci, SCI_GETSELTEXT, 0, (sptr_t) text);
|
||||
|
||||
@ -213,7 +213,9 @@ static gchar *get_default_text(gint idx)
|
||||
|
||||
if (sci_get_lines_selected(doc_list[idx].sci) == 1)
|
||||
{
|
||||
s = g_malloc(sci_get_selected_text_length(doc_list[idx].sci));
|
||||
gint len = sci_get_selected_text_length(doc_list[idx].sci);
|
||||
|
||||
s = g_malloc(len + 1);
|
||||
sci_get_selected_text(doc_list[idx].sci, s);
|
||||
}
|
||||
else if (sci_get_lines_selected(doc_list[idx].sci) == 0)
|
||||
|
||||
@ -180,7 +180,7 @@ void tools_execute_custom_command(gint idx, const gchar *command)
|
||||
|
||||
// get selection
|
||||
len = sci_get_selected_text_length(doc_list[idx].sci);
|
||||
sel = g_malloc0(len);
|
||||
sel = g_malloc0(len + 1);
|
||||
sci_get_selected_text(doc_list[idx].sci, sel);
|
||||
|
||||
// write data to the command
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user