[PHP4BETA] CVS update: php4/ext/standard

From: Date: Thu, 06 May 1999 18:09:50 +0000
Subject: [PHP4BETA] CVS update: php4/ext/standard
Groups: php.version4 
Request: Send a blank email to php-version4+get-667@lists.php.net to get a copy of this message
Date: Thursday May 6, 1999 @ 14:09 Author: zeev Update of /repository/php4/ext/standard In directory php:/tmp/cvs-serv1165/ext/standard Modified Files: info.c post.c Log Message: * Optimize _php3_parse_gpc_data() and clean it up, plus fix a couple of Zend related memory leaks in it Index: php4/ext/standard/info.c diff -u php4/ext/standard/info.c:1.9 php4/ext/standard/info.c:1.10 --- php4/ext/standard/info.c:1.9 Sun May 2 15:54:02 1999 +++ php4/ext/standard/info.c Thu May 6 14:09:50 1999 @@ -269,6 +269,7 @@ switch (_php3_hash_get_current_key((*data)->value.ht, &string_key, &num_key)) { case HASH_KEY_IS_STRING: PUTS(string_key); + efree(string_key); break; case HASH_KEY_IS_LONG: php3_printf("%ld",num_key); @@ -288,6 +289,7 @@ switch (_php3_hash_get_current_key((*data)->value.ht, &string_key, &num_key)) { case HASH_KEY_IS_STRING: PUTS(string_key); + efree(string_key); break; case HASH_KEY_IS_LONG: php3_printf("%ld",num_key); @@ -307,6 +309,7 @@ switch (_php3_hash_get_current_key((*data)->value.ht, &string_key, &num_key)) { case HASH_KEY_IS_STRING: PUTS(string_key); + efree(string_key); break; case HASH_KEY_IS_LONG: php3_printf("%ld",num_key); Index: php4/ext/standard/post.c diff -u php4/ext/standard/post.c:1.6 php4/ext/standard/post.c:1.7 --- php4/ext/standard/post.c:1.6 Sun May 2 14:07:40 1999 +++ php4/ext/standard/post.c Thu May 6 14:09:50 1999 @@ -162,7 +162,7 @@ { int var_type; char *ind, *tmp = NULL, *ret = NULL; - int var_len; + int var_len, val_len; pval *entry; ELS_FETCH(); PLS_FETCH(); @@ -176,7 +176,7 @@ ret = ind; } } - if (var_type & GPC_ARRAY) { /* array (indexed or not */ + if (var_type & GPC_ARRAY) { /* array (indexed or not) */ tmp = strchr(var, '['); if (tmp) { *tmp = '\0'; @@ -201,7 +201,13 @@ } } - tmp = estrdup(val); + val_len = strlen(val); + if (PG(magic_quotes_gpc)) { + val = _php3_addslashes(val, val_len, NULL, 0); + } else { + val = estrndup(val, val_len); + } + if (var_type & GPC_ARRAY) { pval *arr1, *arr2; pval **arr_ptr; @@ -256,23 +262,19 @@ entry = (pval *) emalloc(sizeof(pval)); entry->refcount=1; entry->is_ref=0; - if (PG(magic_quotes_gpc)) { - entry->value.str.val = _php3_addslashes(tmp, 0, &entry->value.str.len, 0); - } else { - entry->value.str.len = strlen(tmp); - entry->value.str.val = estrndup(tmp,entry->value.str.len); - } + entry->value.str.val = val; + entry->value.str.len = val_len; entry->type = IS_STRING; /* And then insert it */ - if (ret) { /* indexed array */ - if (php3_check_type(ret) == IS_LONG) { + if (ret) { /* array */ + if (php3_check_type(ret) == IS_LONG) { /* numeric index */ _php3_hash_index_update(arr1->value.ht, atol(ret), &entry, sizeof(pval *),NULL); /* s[ret]=tmp */ if (track_vars_array) { _php3_hash_index_update(arr2->value.ht, atol(ret), &entry, sizeof(pval *),NULL); entry->refcount++; } - } else { + } else { /* associative index */ _php3_hash_update(arr1->value.ht, ret, strlen(ret)+1, &entry, sizeof(pval *),NULL); /* s["ret"]=tmp */ if (track_vars_array) { _php3_hash_update(arr2->value.ht, ret, strlen(ret)+1, &entry, sizeof(pval *),NULL); @@ -291,23 +293,17 @@ } else { /* we have a normal variable */ pval *entry = (pval *) emalloc(sizeof(pval)); - if (PG(magic_quotes_gpc)) { - entry->value.str.val = _php3_addslashes(tmp, 0, &entry->value.str.len, 0); - } else { - entry->value.str.len = strlen(tmp); - entry->value.str.val = estrndup(tmp,entry->value.str.len); - } entry->type = IS_STRING; entry->refcount=1; entry->is_ref=0; + entry->value.str.val = val; + entry->value.str.len = val_len; _php3_hash_update(EG(active_symbol_table), var, var_len+1, (void *) &entry, sizeof(pval *),NULL); if (track_vars_array) { - pval_copy_constructor(entry); - _php3_hash_update(track_vars_array->value.ht, var, var_len+1, (void *) &entry, sizeof(pval *),NULL); + entry->refcount++; + _php3_hash_update(track_vars_array->value.ht, var, var_len+1, (void *) &entry, sizeof(pval *), NULL); } } - - if (tmp) efree(tmp); } -- PHP 4 Beta

« previous php.version4 (#667) next »