CVS update: php3/functions

From: Date: Sun, 25 Apr 1999 16:26:41 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-5254@lists.php.net to get a copy of this message
Date: Sunday April 25, 1999 @ 12:26 Author: thies Update of /repository/php3/functions In directory php:/tmp/cvs-serv20833/functions Modified Files: oracle.c oracle.h Log Message: fixed mem-leak in ora_bind fixed length of variables returned from ora_bind Index: php3/functions/oracle.c diff -u php3/functions/oracle.c:1.99 php3/functions/oracle.c:1.100 --- php3/functions/oracle.c:1.99 Thu Apr 22 14:12:44 1999 +++ php3/functions/oracle.c Sun Apr 25 12:26:41 1999 @@ -30,7 +30,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oracle.c,v 1.99 1999/04/22 18:12:44 thies Exp $ */ +/* $Id: oracle.c,v 1.100 1999/04/25 16:26:41 thies Exp $ */ #if defined(COMPILE_DL) # if PHP_31 @@ -222,6 +222,20 @@ ORACLE_GLOBAL(php3_oracle_module).num_persistent--; } +static int +pval_ora_param_destructor(oraParam *param) +{ + if (! param) { + return 0; + } + + if (param->progv) { + efree(param->progv); + } + return 0; +} + + static void _close_oracur(oraCursor *cur) { int i; @@ -777,18 +791,6 @@ } /* }}} */ -static void -pval_ora_param_destructor(oraParam *param) -{ - if (! param) { - return; - } - - if (param->progv) { - efree(param->progv); - } -} - /* {{{ proto int ora_bind(int cursor, string php_variable_name, string sql_parameter_name, int length [, int type]) Bind a PHP variable to an Oracle parameter */ void php3_Ora_Bind(INTERNAL_FUNCTION_PARAMETERS) @@ -820,10 +822,7 @@ cursor->params = (HashTable *)emalloc(sizeof(HashTable)); if (!cursor->params || _php3_hash_init(cursor->params, 19, NULL, -/* (void (*)(void *))pval_ora_param_destructor, 0) == FAILURE) { -*/ - (void (*)(void *))NULL, 0) == FAILURE) { php3_error(E_ERROR, "Unable to initialize parameter list"); RETURN_FALSE; } @@ -853,9 +852,9 @@ paramptr->progvl = argv[3]->value.lval + 1; if(argc > 4){ convert_to_long(argv[4]); - paramptr->type = (short)argv[4]->value.lval; + paramptr->inout = (short)argv[4]->value.lval; }else{ - paramptr->type = 0; + paramptr->inout = 0; } if((paramptr->progv = (text *)emalloc(paramptr->progvl)) == NULL){ @@ -865,9 +864,22 @@ /* XXX Maximum for progvl */ paramptr->alen = paramptr->progvl; - if(obndra(&cursor->cda, argv[2]->value.str.val, -1, - (ub1 *)paramptr->progv, paramptr->progvl, SQLT_STR, - -1, 0, &paramptr->alen, 0, 0, 0, 0, -1, -1)){ + + if (obndra(&cursor->cda, + argv[2]->value.str.val, + -1, + (ub1 *)paramptr->progv, + paramptr->progvl, + SQLT_STR, /* ftype */ + -1, /* scale */ + 0/*&paramptr->ind*/, /* ind */ + &paramptr->alen, /* alen */ + 0 /*&paramptr->arcode*/, + 0, /* maxsize */ + 0, + 0, + -1, + -1)) { php3_error(E_WARNING, "Ora_Bind failed (%s)", ora_error(&cursor->cda)); RETURN_FALSE; @@ -1697,6 +1709,7 @@ php3_error(E_WARNING, "Can't get parameter name"); return 0; } + if(_php3_hash_get_current_data(cursor->params, (void **)&param) == FAILURE){ php3_error(E_WARNING, "Can't get parameter data"); efree(paramname); @@ -1704,29 +1717,25 @@ } if(isout){ - /* XXX param->alen + 1 ?? */ - if(param->type != 1 && param->alen > 0){ #if (WIN32|WINNT) /* see oracle_hack.c */ - { - pval var; - char *name=(paramname); - var.value.str.val = (param->progv); - var.value.str.len = (param->alen); - var.type = IS_STRING; - _php3_hash_update(symbol_table, name, strlen(name)+1, &var, sizeof(pval),NULL); - } + { + pval var; + char *name=(paramname); + var.value.str.val = estrdup(param->progv); + var.value.str.len = strlen(param->progv); + var.type = IS_STRING; + _php3_hash_update(symbol_table, name, strlen(name)+1, &var, sizeof(pval),NULL); + } #else - SET_VAR_STRINGL(paramname, param->progv, param->alen); + SET_VAR_STRINGL(paramname, estrdup(param->progv), strlen(param->progv)); #endif - } efree(paramname); continue; - }else if(param->type == 2){ - efree(paramname); - continue; } + /* doing the in-loop */ + /* FIXME Globals don't work in extensions on windows, have to do something else here. See oracle_hack.c */ #if (WIN32|WINNT) @@ -1748,6 +1757,7 @@ } len = min(param->progvl - 1, pdata->value.str.len); + strncpy(param->progv, pdata->value.str.val, len); param->progv[len] = '\0'; Index: php3/functions/oracle.h diff -u php3/functions/oracle.h:1.35 php3/functions/oracle.h:1.36 --- php3/functions/oracle.h:1.35 Mon Dec 28 04:43:58 1998 +++ php3/functions/oracle.h Sun Apr 25 12:26:41 1999 @@ -1,4 +1,4 @@ -/* $Id: oracle.h,v 1.35 1998/12/28 09:43:58 sas Exp $ */ +/* $Id: oracle.h,v 1.36 1999/04/25 16:26:41 thies Exp $ */ #ifndef _PHP3_ORACLE_H #define _PHP3_ORACLE_H @@ -80,7 +80,7 @@ typedef struct oraParam { text *progv; sword progvl; - sb2 type; + sb2 inout; ub2 alen; } oraParam; -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#5254) next »