[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard scanf.c

2009-01-19 Thread Antony Dovgal
tony2001Mon Jan 19 14:41:53 2009 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/standard   scanf.c 
  Log:
  MFH: fix memleaks in sscanf()
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/scanf.c?r1=1.31.2.2.2.7&r2=1.31.2.2.2.8&diff_format=u
Index: php-src/ext/standard/scanf.c
diff -u php-src/ext/standard/scanf.c:1.31.2.2.2.7 
php-src/ext/standard/scanf.c:1.31.2.2.2.8
--- php-src/ext/standard/scanf.c:1.31.2.2.2.7   Wed Dec 31 11:17:45 2008
+++ php-src/ext/standard/scanf.cMon Jan 19 14:41:52 2009
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: scanf.c,v 1.31.2.2.2.7 2008/12/31 11:17:45 sebastian Exp $ */
+/* $Id: scanf.c,v 1.31.2.2.2.8 2009/01/19 14:41:52 tony2001 Exp $ */
 
 /*
scanf.c --
@@ -1066,9 +1066,9 @@
break;
} else if (numVars) {
  /* change passed value type 
to string */
-  current = args[objIndex++];
-  convert_to_string( *current 
);
-  ZVAL_STRING( *current, buf, 
1 );
+   current = 
args[objIndex++];
+   zval_dtor(*current);
+   ZVAL_STRING( *current, 
buf, 1 );
} else {

add_index_string(*return_value, objIndex++, buf, 1);
}
@@ -1077,7 +1077,7 @@
break;
} else if (numVars) {
current = 
args[objIndex++];
-   convert_to_long( 
*current );
+   zval_dtor(*current);
Z_LVAL(**current) = 
value;
} else {

add_index_long(*return_value, objIndex++, value);
@@ -1182,7 +1182,7 @@
break;
} else if (numVars) {
current = args[objIndex++];
-   convert_to_double( *current );
+   zval_dtor(*current);
Z_DVAL_PP( current ) = dvalue;
} else {
add_index_double( 
*return_value, objIndex++, dvalue );



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard scanf.c

2007-07-26 Thread Jani Taskinen
janiThu Jul 26 14:30:22 2007 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/standard   scanf.c 
  Log:
  MFH: cs + ws fixes
  http://cvs.php.net/viewvc.cgi/php-src/ext/standard/scanf.c?r1=1.31.2.2.2.3&r2=1.31.2.2.2.4&diff_format=u
Index: php-src/ext/standard/scanf.c
diff -u php-src/ext/standard/scanf.c:1.31.2.2.2.3 
php-src/ext/standard/scanf.c:1.31.2.2.2.4
--- php-src/ext/standard/scanf.c:1.31.2.2.2.3   Sat Feb 24 02:17:27 2007
+++ php-src/ext/standard/scanf.cThu Jul 26 14:30:22 2007
@@ -1,4 +1,4 @@
-/* 
+/*
+--+
| PHP Version 5|
+--+
@@ -16,16 +16,14 @@
+--+
 */
 
-/* $Id: scanf.c,v 1.31.2.2.2.3 2007/02/24 02:17:27 helly Exp $ */
+/* $Id: scanf.c,v 1.31.2.2.2.4 2007/07/26 14:30:22 jani Exp $ */
 
 /*
-   scanf.c --
- 
+   scanf.c --
+
This file contains the base code which implements sscanf and by 
extension
-   fscanf. Original code is from TCL8.3.0 and bears the following copyright
- 
- 
- 
+   fscanf. Original code is from TCL8.3.0 and bears the following 
copyright:
+
This software is copyrighted by the Regents of the University of
California, Sun Microsystems, Inc., Scriptics Corporation,
and other parties.  The following terms apply to all files associated
@@ -46,7 +44,7 @@
ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-   
+
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
@@ -56,7 +54,7 @@
 
GOVERNMENT USE: If you are acquiring this software on behalf of the
U.S. government, the Government shall have only "Restricted Rights"
-   in the software and related documentation as defined in the Federal 
+   in the software and related documentation as defined in the Federal
Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you
are acquiring the software on behalf of the Department of Defense, the
software shall be classified as "Commercial Computer Software" and the
@@ -64,17 +62,16 @@
252.227-7013 (c) (1) of DFARs.  Notwithstanding the foregoing, the
authors grant the U.S. Government and others acting in its behalf
permission to use and distribute the software in accordance with the
-   terms specified in this license. 
- 
- */
- 
+   terms specified in this license.
+*/
+
 #include 
 #include 
 #include 
 #include "php.h"
 #include "php_variables.h"
 #ifdef HAVE_LOCALE_H
-#include  
+#include 
 #endif
 #include "zend_execute.h"
 #include "zend_operators.h"
@@ -86,7 +83,6 @@
 /*
  * Flag values used internally by [f|s]canf.
  */
-
 #define SCAN_NOSKIP 0x1   /* Don't skip blanks. */
 #define SCAN_SUPPRESS  0x2   /* Suppress assignment. */
 #define SCAN_UNSIGNED  0x4   /* Read an unsigned value. */
@@ -101,13 +97,10 @@
 
 #define UCHAR(x)   (zend_uchar)(x)
 
-
-
 /*
  * The following structure contains the information associated with
  * a character set.
  */
-
 typedef struct CharSet {
int exclude;/* 1 if this is an exclusion set. */
int nchars;
@@ -122,7 +115,6 @@
 /*
  * Declarations for functions used only in this file.
  */
-
 static char *BuildCharSet(CharSet *cset, char *format);
 static int CharInSet(CharSet *cset, int ch);
 static voidReleaseCharSet(CharSet *cset);
@@ -153,18 +145,17 @@
char *end;
 
memset(cset, 0, sizeof(CharSet));
-   
+
ch = format;
if (*ch == '^') {
cset->exclude = 1;
ch = ++format;
}
-   end = format + 1;/* verify this - cc */
+   end = format + 1;   /* verify this - cc */
 
/*
 * Find the close bracket so we can overallocate the set.
 */
-
if (*ch == ']') {
ch = end++;
}
@@ -186,7 +177,6 @@
/*
 * Now build the character set.
 */
-
cset->nchars = cset->nranges = 0;
ch= format++;
start = *ch;
@@ -200,7 +190,6 @@
 * This may be the first character of a range, so don't 
add
 * it yet.
 */
-
start = *ch;
} else if (*ch == '-') {
/*
@@ -208,7 +197,6 @@
 * case it is not a range and we should add the 
previous character
 * as well as the dash.