[augeas-devel] augeas: master - Allow passing NULL regexps in some regexp routines

David Lutterkort lutter at fedoraproject.org
Fri Feb 13 19:50:52 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=1b0fd54d9c0a43e9ca0293914cd31477fcfa0968
Commit:        1b0fd54d9c0a43e9ca0293914cd31477fcfa0968
Parent:        fd1c991ff244218e19aa65ad3d54818ac387b7ec
Author:        David Lutterkort <lutter at redhat.com>
AuthorDate:    Sun Dec 14 23:38:15 2008 -0800
Committer:     David Lutterkort <lutter at redhat.com>
CommitterDate: Fri Feb 13 11:45:45 2009 -0800

Allow passing NULL regexps in some regexp routines

---
 src/regexp.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/regexp.c b/src/regexp.c
index 797d0e6..e49dcff 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -229,10 +229,14 @@ regexp_minus(struct info *info, struct regexp *r1, struct regexp *r2) {
 
 struct regexp *
 regexp_iter(struct info *info, struct regexp *r, int min, int max) {
-    const char *p = r->pattern->str;
+    const char *p;
     char *s;
     int ret = 0;
 
+    if (r == NULL)
+        return NULL;
+
+    p = r->pattern->str;
     if ((min == 0 || min == 1) && max == -1) {
         char q = (min == 0) ? '*' : '+';
         ret = asprintf(&s, "(%s)%c", p, q);
@@ -246,10 +250,13 @@ regexp_iter(struct info *info, struct regexp *r, int min, int max) {
 
 struct regexp *
 regexp_maybe(struct info *info, struct regexp *r) {
-    const char *p = r->pattern->str;
+    const char *p;
     char *s;
     int ret;
 
+    if (r == NULL)
+        return NULL;
+    p = r->pattern->str;
     ret = asprintf(&s, "(%s)?", p);
     return (ret == -1) ? NULL : make_regexp(info, s);
 }




More information about the augeas-devel mailing list