]> granicus.if.org Git - php/commitdiff
off by one error
authorGeorge Schlossnagle <gschlossnagle@php.net>
Thu, 20 May 2004 18:44:12 +0000 (18:44 +0000)
committerGeorge Schlossnagle <gschlossnagle@php.net>
Thu, 20 May 2004 18:44:12 +0000 (18:44 +0000)
ext/pdo/pdo_sql_parser.c
ext/pdo/pdo_sql_parser.re

index ddc86ca37da1a94f892de018ecfc3a0434d4edba..5e112ec26fb8ea47142d1a9a1328ca19e46928f6 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.5 on Thu May 20 13:12:59 2004 */
+/* Generated by re2c 0.5 on Thu May 20 13:51:55 2004 */
 #line 1 "/home/george/src/pecl/pdo/pdo_sql_parser.re"
 /*
   +----------------------------------------------------------------------+
@@ -232,12 +232,14 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
                        if(!params) { 
                                /* error */
                                efree(*outquery);
+                               *outquery = NULL;
                                return (int) (s.cur - inquery);
                        }
                        /* lookup bind first via hash and then index */
                        /* stupid keys need to be null-terminated, even though we know their length */
-                       crutch  = s.tok[s.cur-s.tok + 1];
+                       crutch  = s.tok[s.cur-s.tok];
                        s.tok[s.cur-s.tok] = '\0';
+fprintf(stderr, "looking up key: (%.*s)", s.cur-s.tok + 1, s.tok);
                        if((SUCCESS == zend_hash_find(params, s.tok, s.cur-s.tok + 1,(void **)&param))  
                            ||
                           (SUCCESS == zend_hash_index_find(params, bindno, (void **)&param))) 
@@ -265,6 +267,7 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
                        else {
                                /* error and cleanup */
                                efree(*outquery);
+                               *outquery = NULL;
                                return (int) (s.cur - inquery);
                        }
                        bindno++;
@@ -273,6 +276,7 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
                        if(!params) { 
                                /* error */
                                efree(*outquery);
+                               *outquery = NULL;
                                return (int) (s.cur - inquery);
                        }
                        /* lookup bind by index */
@@ -299,12 +303,14 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
                        else {
                                /* error and cleanup */
                                efree(*outquery);
+                               *outquery = NULL;
                                return (int) (s.cur - inquery);
                        }
                        bindno++;
                }
        }       
        *ptr = '\0';
+fprintf(stderr, "good\n");
        return 0;
 }
 
index 83ce3d2538e65619be74f603fe329da9c8217355..1282fb5e501668b1ee4cca3b3f77fff3981b7db3 100644 (file)
@@ -121,7 +121,7 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
                        }
                        /* lookup bind first via hash and then index */
                        /* stupid keys need to be null-terminated, even though we know their length */
-                       crutch  = s.tok[s.cur-s.tok + 1];
+                       crutch  = s.tok[s.cur-s.tok];
                        s.tok[s.cur-s.tok] = '\0';
                        if((SUCCESS == zend_hash_find(params, s.tok, s.cur-s.tok + 1,(void **)&param))  
                            ||
@@ -147,7 +147,7 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
                                        *outquery_len += (Z_STRLEN_P(param->parameter));
                                }
                        }
-                       else_{
+                       else {
                                /* error and cleanup */
                                efree(*outquery);
                                *outquery = NULL;