Revision: 1765 http://geany.svn.sourceforge.net/geany/?rev=1765&view=rev Author: ntrel Date: 2007-07-30 03:40:09 -0700 (Mon, 30 Jul 2007)
Log Message: ----------- Add allocation for NULL-terminated selection ends.
Modified Paths: -------------- trunk/ChangeLog trunk/src/callbacks.c trunk/src/sciwrappers.c trunk/src/search.c trunk/src/tools.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-29 19:12:27 UTC (rev 1764) +++ trunk/ChangeLog 2007-07-30 10:40:09 UTC (rev 1765) @@ -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:
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2007-07-29 19:12:27 UTC (rev 1764) +++ trunk/src/callbacks.c 2007-07-30 10:40:09 UTC (rev 1765) @@ -1902,7 +1902,9 @@
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)
Modified: trunk/src/sciwrappers.c =================================================================== --- trunk/src/sciwrappers.c 2007-07-29 19:12:27 UTC (rev 1764) +++ trunk/src/sciwrappers.c 2007-07-30 10:40:09 UTC (rev 1765) @@ -509,6 +509,8 @@ }
+/* 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);
Modified: trunk/src/search.c =================================================================== --- trunk/src/search.c 2007-07-29 19:12:27 UTC (rev 1764) +++ trunk/src/search.c 2007-07-30 10:40:09 UTC (rev 1765) @@ -213,7 +213,9 @@
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)
Modified: trunk/src/tools.c =================================================================== --- trunk/src/tools.c 2007-07-29 19:12:27 UTC (rev 1764) +++ trunk/src/tools.c 2007-07-30 10:40:09 UTC (rev 1765) @@ -180,7 +180,7 @@
// 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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.