]> granicus.if.org Git - php/commitdiff
fix leaks and add one more NULL check
authorAnatol Belski <ab@php.net>
Mon, 29 Feb 2016 14:38:42 +0000 (15:38 +0100)
committerAnatol Belski <ab@php.net>
Mon, 29 Feb 2016 14:38:42 +0000 (15:38 +0100)
ext/pdo_dblib/dblib_stmt.c

index 387648244f6c7af8c06a0b8da3039e5d564087bc..2830272b8273eafb630638e8a0168becfb2e7165 100644 (file)
@@ -104,10 +104,16 @@ static int pdo_dblib_stmt_cursor_closer(pdo_stmt_t *stmt TSRMLS_DC)
        dbcancel(H->link);
        
        if (stmt->columns) {
+               int i = 0;
+               for (; i < stmt->column_count; i++) {
+                       if (stmt->columns[i].name) {
+                               efree(stmt->columns[i].name);
+                       }
+               }
                efree(stmt->columns); 
                stmt->columns = NULL;
        }
-       
+
        return 1;
 }
 
@@ -115,8 +121,16 @@ static int pdo_dblib_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC)
 {
        pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
 
-       efree(stmt->columns); 
-       stmt->columns = NULL;
+       if (stmt->columns) {
+               int i = 0;
+               for (; i < stmt->column_count; i++) {
+                       if (stmt->columns[i].name) {
+                               efree(stmt->columns[i].name);
+                       }
+               }
+               efree(stmt->columns); 
+               stmt->columns = NULL;
+       }
 
        efree(S);