]> granicus.if.org Git - php/commitdiff
Don't segault when we have placeholders but no bound params
authorEdin Kadribasic <edink@php.net>
Sun, 6 Feb 2005 00:46:17 +0000 (00:46 +0000)
committerEdin Kadribasic <edink@php.net>
Sun, 6 Feb 2005 00:46:17 +0000 (00:46 +0000)
ext/pdo/pdo_sql_parser.c
ext/pdo/pdo_sql_parser.re

index 10484f059b599374f08c91cd2c451061bedeb2af..ece456c0a5f8283afb9926633c57358eff17413d 100644 (file)
@@ -1,5 +1,5 @@
-/* Generated by re2c 0.9.3 on Thu Jan 20 22:49:12 2005 */
-#line 1 "pdo_sql_parser.re" 
+/* Generated by re2c 0.9.3 on Sun Feb  6 01:46:44 2005 */
+#line 1 "pdo_sql_parser.re"
 /*
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
@@ -275,6 +275,13 @@ PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len,
 
        params = stmt->bound_params;
        
+       /* Do we have placeholders but no bound params */
+       if (bindno && !params) {
+               strcpy(stmt->error_code, "HY093"); /* invalid parameter number */
+               ret = -1;
+               goto clean_up;
+       }
+       
        /* what are we going to do ? */
        
        if (stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) {
index 09c81ffe926ab5bd537bc0adaa6e1e5da7a20f45..6517270d0637f36421221d68c66464c0720d4061 100644 (file)
@@ -138,6 +138,13 @@ PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len,
 
        params = stmt->bound_params;
        
+       /* Do we have placeholders but no bound params */
+       if (bindno && !params) {
+               strcpy(stmt->error_code, "HY093"); /* invalid parameter number */
+               ret = -1;
+               goto clean_up;
+       }
+       
        /* what are we going to do ? */
        
        if (stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) {