]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-5.6' into PHP-7.0
authorAnatol Belski <ab@php.net>
Mon, 29 Feb 2016 14:48:51 +0000 (15:48 +0100)
committerAnatol Belski <ab@php.net>
Mon, 29 Feb 2016 14:48:51 +0000 (15:48 +0100)
* PHP-5.6:
  fix leaks and add one more NULL check
  add NULL check
  fix C89 compat
  fix arg type

1  2 
ext/pdo_dblib/dblib_driver.c
ext/pdo_dblib/dblib_stmt.c

index cfb386fa0d26c4dc692c32bebd9524cd6d441825,70b440298213260348b12d21f09cf99838f7a916..dcbaf55a3fa9192a52f38d572ee412747aedd1f5
@@@ -329,11 -283,9 +329,9 @@@ static int pdo_dblib_handle_factory(pdo
  #endif
                ,{"10.0",DBVERSION_100}
                ,{"auto",0} /* Only works with FreeTDS. Other drivers will bork */
 -              
 +
        };
-       nvers = sizeof(tdsver)/sizeof(tdsver[0]);
+       
        struct pdo_data_src_parser vars[] = {
                { "charset",    NULL,   0 }
                ,{ "appname",   "PHP " PDO_DBLIB_FLAVOUR,       0 }
                ,{ "secure",    NULL,   0 } /* DBSETLSECURE */
                ,{ "version",   NULL,   0 } /* DBSETLVERSION */
        };
 -      
 +
        nvars = sizeof(vars)/sizeof(vars[0]);
+       nvers = sizeof(tdsver)/sizeof(tdsver[0]);
+       
        php_pdo_parse_data_source(dbh->data_source, dbh->data_source_len, vars, nvars);
  
 +      if (driver_options) {
 +              int timeout = pdo_attr_lval(driver_options, PDO_ATTR_TIMEOUT, 30);
 +              dbsetlogintime(timeout); /* Connection/Login Timeout */
 +              dbsettime(timeout); /* Statement Timeout */
 +      }
 +
        H = pecalloc(1, sizeof(*H), dbh->is_persistent);
        H->login = dblogin();
        H->err.sqlstate = dbh->error_code;
index 484bfbb560d614c8a24469b8c0677d3e3989ff82,2830272b8273eafb630638e8a0168becfb2e7165..43802264b68da8a9119da93bacfc93f4202d2c2b
@@@ -102,6 -102,17 +102,17 @@@ static int pdo_dblib_stmt_cursor_closer
  
        /* Cancel any pending results */
        dbcancel(H->link);
 -                              efree(stmt->columns[i].name);
+       
+       if (stmt->columns) {
+               int i = 0;
+               for (; i < stmt->column_count; i++) {
+                       if (stmt->columns[i].name) {
++                              zend_string_release(stmt->columns[i].name);
+                       }
+               }
+               efree(stmt->columns); 
+               stmt->columns = NULL;
+       }
  
        return 1;
  }
@@@ -110,8 -121,19 +121,19 @@@ static int pdo_dblib_stmt_dtor(pdo_stmt
  {
        pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
  
 -                              efree(stmt->columns[i].name);
+       if (stmt->columns) {
+               int i = 0;
+               for (; i < stmt->column_count; i++) {
+                       if (stmt->columns[i].name) {
++                              zend_string_release(stmt->columns[i].name);
+                       }
+               }
+               efree(stmt->columns); 
+               stmt->columns = NULL;
+       }
        efree(S);
 -              
 +
        return 1;
  }