com php-src: Fixed ext/fileinfo conversion mistakes: ext/fileinfo/libmagic/softmagic.c
| From: | Dmitry Stogov | Date: | Wed, 07 May 2014 13:58:28 +0000 |
| Subject: | com php-src: Fixed ext/fileinfo conversion mistakes: ext/fileinfo/libmagic/softmagic.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-78182@lists.php.net to get a copy of this message | ||
Commit: 449ea00a48135e96a4f79841c4988c19ab1b58c0
Author: Dmitry Stogov <dmitry@zend.com> Wed, 7 May 2014 17:58:28 +0400
Parents: e75f2d1f763ad84d4450c646466066960720fc91
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=449ea00a48135e96a4f79841c4988c19ab1b58c0
Log:
Fixed ext/fileinfo conversion mistakes
Changed paths:
M ext/fileinfo/libmagic/softmagic.c
Diff:
diff --git a/ext/fileinfo/libmagic/softmagic.c b/ext/fileinfo/libmagic/softmagic.c
index fb275f7..bfcae28 100644
--- a/ext/fileinfo/libmagic/softmagic.c
+++ b/ext/fileinfo/libmagic/softmagic.c
@@ -2102,12 +2102,17 @@ magiccheck(struct magic_set *ms, struct magic *m)
zval *pzval;
HashTable *ht = Z_ARRVAL(subpats);
zval *pattern_match = NULL, *pattern_offset = NULL;
+ int first = 1, inner_first;
ZEND_HASH_FOREACH_VAL(ht, pzval) {
HashTable *inner_ht;
zval *match, *offset;
zval tmpcopy, matchcopy, offsetcopy;
+ if (first) {
+ first = 0;
+ continue;
+ }
ZVAL_DUP(&tmpcopy, pzval);
inner_ht = Z_ARRVAL(tmpcopy);
@@ -2116,34 +2121,44 @@ magiccheck(struct magic_set *ms, struct magic *m)
tmpcopy now contains two elements:
0 = the match
1 = starting position of the match */
+ inner_first = 1;
ZEND_HASH_FOREACH_VAL(inner_ht, match) {
+ if (inner_first) {
+ inner_first = 0;
+ continue;
+ }
ZVAL_DUP(&matchcopy, match);
convert_to_string(&matchcopy);
pattern_match = &matchcopy;
} ZEND_HASH_FOREACH_END();
+ inner_first = 1;
ZEND_HASH_FOREACH_VAL(inner_ht, offset) {
+ if (inner_first) {
+ inner_first = 0;
+ continue;
+ }
ZVAL_DUP(&offsetcopy, offset);
convert_to_long(&offsetcopy);
pattern_offset = &offsetcopy;
} ZEND_HASH_FOREACH_END();
zval_dtor(&tmpcopy);
- } ZEND_HASH_FOREACH_END();
- if ((pattern_match != NULL) && (pattern_offset != NULL)) {
- ms->search.s += Z_LVAL_P(pattern_offset); /* this is where the match starts */
- ms->search.offset += Z_LVAL_P(pattern_offset); /* this is where the match starts as size_t
*/
- ms->search.rm_len = Z_STRLEN_P(pattern_match) /* This is the length of the matched pattern
*/;
- v = 0;
-
- zval_ptr_dtor(pattern_match);
- zval_ptr_dtor(pattern_offset);
- } else {
- zval_ptr_dtor(&subpats);
- zval_ptr_dtor(&pattern);
- return -1;
- }
+ if ((pattern_match != NULL) && (pattern_offset != NULL)) {
+ ms->search.s += Z_LVAL_P(pattern_offset); /* this is where the match starts */
+ ms->search..offset += Z_LVAL_P(pattern_offset); /* this is where the match starts as
size_t */
+ ms->search.rm_len = Z_STRLEN_P(pattern_match) /* This is the length of the matched pattern
*/;
+ v = 0;
+
+ zval_ptr_dtor(pattern_match);
+ zval_ptr_dtor(pattern_offset);
+ } else {
+ zval_ptr_dtor(&subpats);
+ zval_ptr_dtor(&pattern);
+ return -1;
+ }
+ } ZEND_HASH_FOREACH_END();
} else {
v = 1;
}