SF.net SVN: geany:[5544] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Tue Feb 22 17:15:29 UTC 2011
Revision: 5544
http://geany.svn.sourceforge.net/geany/?rev=5544&view=rev
Author: ntrel
Date: 2011-02-22 17:15:29 +0000 (Tue, 22 Feb 2011)
Log Message:
-----------
Fix segfault when inserting e.g. fileheader template when the
template file is empty (#3070913, thanks to lphilpot).
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/templates.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-02-21 19:09:34 UTC (rev 5543)
+++ trunk/ChangeLog 2011-02-22 17:15:29 UTC (rev 5544)
@@ -1,3 +1,10 @@
+2011-02-22 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/templates.c:
+ Fix segfault when inserting e.g. fileheader template when the
+ template file is empty (#3070913, thanks to lphilpot).
+
+
2011-02-21 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* plugins/filebrowser.c:
Modified: trunk/src/templates.c
===================================================================
--- trunk/src/templates.c 2011-02-21 19:09:34 UTC (rev 5543)
+++ trunk/src/templates.c 2011-02-22 17:15:29 UTC (rev 5544)
@@ -508,12 +508,15 @@
/* add line_prefix to every line of comment_text */
lines = g_strsplit(comment_text->str, template_eol_char, -1);
- len = g_strv_length(lines) - 1;
- for (i = 0; i < len; i++)
+ len = g_strv_length(lines);
+ if (len > 0) /* prevent unsigned wraparound if comment_text is empty */
{
- tmp = lines[i];
- lines[i] = g_strconcat(prefix, tmp, NULL);
- g_free(tmp);
+ for (i = 0; i < len - 1; i++)
+ {
+ tmp = lines[i];
+ lines[i] = g_strconcat(prefix, tmp, NULL);
+ g_free(tmp);
+ }
}
tmp = g_strjoinv(template_eol_char, lines);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list