[augeas-devel] [PATCH] Check for NULL values in the put direction of store

David Lutterkort dlutter at redhat.com
Mon Jul 7 17:45:49 UTC 2008


1 file changed, 5 insertions(+), 2 deletions(-)
src/put.c |    7 +++++--


# HG changeset patch
# User David Lutterkort <dlutter at redhat.com>
# Date 1215452738 25200
# Node ID 6a197e343002072ecebe7578a8ef1b309231ac68
# Parent  0dae0cabcd63482e1e7a48c7334d13998cbd7c35
Check for NULL values in the put direction of store

This is now flagged as an error instead of causing a segfault.

diff -r 0dae0cabcd63 -r 6a197e343002 src/put.c
--- a/src/put.c	Thu Jul 03 22:22:53 2008 -0700
+++ b/src/put.c	Mon Jul 07 10:45:38 2008 -0700
@@ -505,8 +505,11 @@
 }
 
 static void put_store(struct lens *lens, struct state *state) {
-    if (regexp_match(lens->regexp, state->value, strlen(state->value),
-                     0, NULL) != strlen(state->value)) {
+    if (state->value == NULL) {
+        put_error(state, lens,
+                  "Can not store a nonexistent (NULL) value");
+    } else if (regexp_match(lens->regexp, state->value, strlen(state->value),
+                            0, NULL) != strlen(state->value)) {
         put_error(state, lens,
                   "Value '%s' does not match regexp /%s/ in store lens",
                   state->value, lens->regexp->pattern->str);




More information about the augeas-devel mailing list