summaryrefslogtreecommitdiff
path: root/glib/gregex.c
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2022-07-15 01:27:33 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2022-07-15 01:46:11 +0200
commitc05d09044fb71bdea599c81bf0ae896a5503e76a (patch)
treef8816d2a21064a11b30956ae5d141c976ef9f4dd /glib/gregex.c
parentc1eb93d2a264372f35f140fef3777aea20595f71 (diff)
downloadglib-c05d09044fb71bdea599c81bf0ae896a5503e76a.tar.gz
gregex: Ensure we translate the errcode without asserting on G_REGEX_ERROR_COMPILE
Since commit 8d5a44dc in order to ensure that we were setting the errcode in translate_compile_error(), we did an assert checking whether it was a valid value, but we assumed that 0 was not a valid error, while it is as it's the generic G_REGEX_ERROR_COMPILE. So, set errcode and errmsg to invalid values before translating and ensure we've change them. Fixes: #2694
Diffstat (limited to 'glib/gregex.c')
-rw-r--r--glib/gregex.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/glib/gregex.c b/glib/gregex.c
index 5fc7b16bc..2a54929bf 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -476,8 +476,12 @@ translate_compile_error (gint *errcode, const gchar **errmsg)
* Note that there can be more PCRE errors with the same GRegexError
* and that some PCRE errors are useless for us.
*/
+ gint original_errcode = *errcode;
- switch (*errcode)
+ *errcode = -1;
+ *errmsg = NULL;
+
+ switch (original_errcode)
{
case PCRE2_ERROR_END_BACKSLASH:
*errcode = G_REGEX_ERROR_STRAY_BACKSLASH;
@@ -725,7 +729,7 @@ translate_compile_error (gint *errcode, const gchar **errmsg)
break;
}
- g_assert (*errcode != 0);
+ g_assert (*errcode != -1);
g_assert (*errmsg != NULL);
}