[geany/geany-plugins] 1839e1: pohelper: Fix infinite loop retrieving a message's translation
Colomban Wendling
git-noreply at xxxxx
Mon Feb 16 22:59:15 UTC 2015
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Mon, 27 May 2013 02:44:06 UTC
Commit: 1839e168da603e86039d4cb3ca9dca350ea4ac8d
https://github.com/geany/geany-plugins/commit/1839e168da603e86039d4cb3ca9dca350ea4ac8d
Log Message:
-----------
pohelper: Fix infinite loop retrieving a message's translation
Fix an infinite loop in get_msgstr_text_at() if there was only default
style after it until the end of the document.
sci_get_style_at() returns 0 if the position was invalid, which happens
to be the value of SCE_PO_DEFAULT, so simply looping while it matched
entered an infinite loop at the end of the document. So, additionally
make sure the position is inside the document's range.
Modified Paths:
--------------
pohelper/src/gph-plugin.c
Modified: pohelper/src/gph-plugin.c
3 lines changed, 2 insertions(+), 1 deletions(-)
===================================================================
@@ -702,6 +702,7 @@ get_msgstr_text_at (GeanyDocument *doc,
if (pos >= 0) {
ScintillaObject *sci = doc->editor->sci;
GString *msgstr = g_string_new (NULL);
+ gint length = sci_get_length (sci);
while (sci_get_style_at (sci, pos) == SCE_PO_MSGSTR_TEXT) {
pos++; /* skip opening quote */
@@ -712,7 +713,7 @@ get_msgstr_text_at (GeanyDocument *doc,
pos++; /* skip closing quote */
/* skip until next non-default style */
- while (sci_get_style_at (sci, pos) == SCE_PO_DEFAULT) {
+ while (pos < length && sci_get_style_at (sci, pos) == SCE_PO_DEFAULT) {
pos++;
}
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Plugins-Commits
mailing list