Branch: refs/heads/master Author: Enrico Tröger enrico.troeger@uvena.de Committer: Enrico Tröger enrico.troeger@uvena.de Date: Thu, 11 Sep 2014 17:16:24 UTC Commit: d6d836c59fc522fcbb96fab7917311c2c6613ea7 https://github.com/geany/geany/commit/d6d836c59fc522fcbb96fab7917311c2c6613e...
Log Message: ----------- Don't match regexes on empty strings
Save As on an empty document would cause warnings like: sys:1: Warning: g_regex_match_full: assertion 'string != NULL' failed because SCI_GETRANGEPOINTER returns NULL then. On a Ubuntu 12.04 system this warning even crashed Geany at writing the log message. So, simply don't search for anything if the document is empty.
Modified Paths: -------------- src/search.c
Modified: src/search.c 7 lines changed, 6 insertions(+), 1 deletions(-) =================================================================== @@ -1968,10 +1968,15 @@ static gint find_regex(ScintillaObject *sci, guint pos, GRegex *regex, GeanyMatc { const gchar *text; GMatchInfo *minfo; + guint document_length; gint ret = -1; gint offset = 0;
- g_return_val_if_fail(pos <= (guint)sci_get_length(sci), -1); + document_length = (guint)sci_get_length(sci); + if (document_length <= 0) + return -1; /* skip empty documents */ + + g_return_val_if_fail(pos <= document_length, -1);
if (g_regex_get_compile_flags(regex) & G_REGEX_MULTILINE) {
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).