]> git.sur5r.net Git - openldap/commitdiff
ITS#6831 don't push stack unless needed
authorHoward Chu <hyc@openldap.org>
Sat, 4 Jun 2011 05:22:48 +0000 (22:22 -0700)
committerHoward Chu <hyc@openldap.org>
Sat, 4 Jun 2011 05:22:48 +0000 (22:22 -0700)
servers/slapd/overlays/pcache.c

index 4fc84cdaf5db5cce4219be6d3920993a09602b56..6875b19fa7a62a1cbc0ab2244e1cbd58083c947d 100644 (file)
@@ -1352,14 +1352,16 @@ nextpass:                       eqpass = 1;
                        switch (fs->f_choice) {
                        case LDAP_FILTER_OR:
                        case LDAP_FILTER_AND:
+                               if ( fs->f_next ) {
+                                       /* save our stack position */
+                                       fsp = op->o_tmpalloc(sizeof(fstack), op->o_tmpmemctx);
+                                       fsp->fs_next = stack;
+                                       fsp->fs_fs = fs->f_next;
+                                       fsp->fs_fi = fi->f_next;
+                                       stack = fsp;
+                               }
                                fs = fs->f_and;
                                fi = fi->f_and;
-                               /* save our stack position */
-                               fsp = op->o_tmpalloc(sizeof(fstack), op->o_tmpmemctx);
-                               fsp->fs_next = stack;
-                               fsp->fs_fs = fs->f_next;
-                               fsp->fs_fi = fi->f_next;
-                               stack = fsp;
                                res=1;
                                break;
                        case LDAP_FILTER_SUBSTRINGS:
@@ -1408,6 +1410,7 @@ nextpass:                 eqpass = 1;
                                break;
                        }
                        if (!fs && !fi && stack) {
+                               /* pop the stack */
                                fsp = stack;
                                stack = fsp->fs_next;
                                fs = fsp->fs_fs;