diff options
author | Dave Davenport <qball@gmpclient.org> | 2019-02-10 14:32:21 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2019-02-10 14:32:21 +0100 |
commit | 3c56761a76dd3ab0aa50ff7d982098582c5a2766 (patch) | |
tree | cc6ff2259da97cbc88a76166014cbb77077a4ac5 /source/helper.c | |
parent | f49866bd8bda2be2d02907dbf090928ff89fe930 (diff) |
[Helper] Add more error checking/reporting.
Diffstat (limited to 'source/helper.c')
-rw-r--r-- | source/helper.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/source/helper.c b/source/helper.c index 41d5f14f..8dde6627 100644 --- a/source/helper.c +++ b/source/helper.c @@ -1288,11 +1288,14 @@ char *helper_string_replace_if_exists ( char * string, ... ) */ char *helper_string_replace_if_exists_v ( char * string, GHashTable *h ) { - GError *error = NULL; + GError *error = NULL; + char *res = NULL; // Replace hits within {-\w+}. - GRegex *reg = g_regex_new ( "\\[(.*)({[-\\w]+})(.*)\\]|({[\\w-]+})", 0, 0, NULL ); - char *res = g_regex_replace_eval ( reg, string, -1, 0, 0, helper_eval_cb2, h, NULL ); + GRegex *reg = g_regex_new ( "\\[(.*)({[-\\w]+})(.*)\\]|({[\\w-]+})", 0, 0, &error ); + if ( error == NULL ){ + res = g_regex_replace_eval ( reg, string, -1, 0, 0, helper_eval_cb2, h, &error ); + } // Free regex. g_regex_unref ( reg ); // Throw error if shell parsing fails. |