]> git.deb.at Git - pkg/abook.git/commitdiff
- make sure that len - 1 is never < 0
authorJaakko Heinonen <jheinonen@users.sourceforge.net>
Wed, 6 Sep 2006 08:48:33 +0000 (08:48 +0000)
committerJaakko Heinonen <jheinonen@users.sourceforge.net>
Wed, 6 Sep 2006 08:48:33 +0000 (08:48 +0000)
- add some asserts

options.c

index 28aaf7c1268de317c0fd4b8df83d2c8e872a7b5e..84f08ca64152564978f04c6821751835602f10d6 100644 (file)
--- a/options.c
+++ b/options.c
@@ -279,11 +279,12 @@ opt_set_set_option(char *p, struct option *opt)
 {
        int len;
 
-       strtrim(p);
+       assert(p);
 
+       strtrim(p);
        len = strlen(p);
 
-       if(p[len - 1] == '\"' && *p == '\"') {
+       if(*p == '\"' && p[len - 1] == '\"') {
                if(len < 3)
                        return _("invalid value");
                p[len - 1] = 0;
@@ -318,6 +319,9 @@ opt_set_option(char *var, char *p)
 {
        int i;
 
+       assert(var);
+       assert(p);
+
        for(i = 0; abook_vars[i].option; i++)
                if(!strcmp(abook_vars[i].option, var))
                        return opt_set_set_option(p, &abook_vars[i]);