diff --git a/Zend/zend.h b/Zend/zend.h index 163b48015d9b8..aff48ca0e2068 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -152,12 +152,12 @@ struct _zend_class_entry { zend_class_entry *parent; zend_string *parent_name; }; - int refcount; + uint32_t refcount; uint32_t ce_flags; uint32_t ce_flags2; int default_properties_count; - int default_static_members_count; + uint32_t default_static_members_count; zval *default_properties_table; zval *default_static_members_table; ZEND_MAP_PTR_DEF(zval *, static_members_table); diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 27a07fffc733b..97e36d6b2498a 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -519,7 +519,7 @@ ZEND_API zend_string *zend_get_compiled_filename(void) /* {{{ */ } /* }}} */ -ZEND_API int zend_get_compiled_lineno(void) /* {{{ */ +ZEND_API uint32_t zend_get_compiled_lineno(void) /* {{{ */ { return CG(zend_lineno); } @@ -4697,7 +4697,7 @@ static const zend_frameless_function_info *find_frameless_function_info(zend_ast static uint32_t zend_compile_frameless_icall_ex(znode *result, zend_ast_list *args, zend_function *fbc, const zend_frameless_function_info *frameless_function_info, uint32_t type) { - int lineno = CG(zend_lineno); + uint32_t lineno = CG(zend_lineno); uint32_t num_args = frameless_function_info->num_args; uint32_t offset = find_frameless_function_offset(num_args, frameless_function_info->handler); znode arg_zvs[3]; diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 8321e4a03c1e3..e8b429bc4696a 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -894,7 +894,7 @@ void shutdown_scanner(void); ZEND_API zend_string *zend_set_compiled_filename(zend_string *new_compiled_filename); ZEND_API void zend_restore_compiled_filename(zend_string *original_compiled_filename); ZEND_API zend_string *zend_get_compiled_filename(void); -ZEND_API int zend_get_compiled_lineno(void); +ZEND_API uint32_t zend_get_compiled_lineno(void); ZEND_API size_t zend_get_scanned_file_offset(void); ZEND_API zend_string *zend_get_compiled_variable_name(const zend_op_array *op_array, uint32_t var); diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index fa24128ae20ed..ef81ae5faaf25 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -88,7 +88,7 @@ struct _zend_compiler_globals { zend_string *compiled_filename; - int zend_lineno; + uint32_t zend_lineno; zend_op_array *active_op_array; @@ -204,7 +204,7 @@ struct _zend_executor_globals { zend_execute_data *current_observed_frame; - int ticks_count; + uint32_t ticks_count; zend_long precision; @@ -343,7 +343,7 @@ struct _zend_ini_scanner_globals { zend_stack state_stack; zend_string *filename; - int lineno; + uint32_t lineno; /* Modes are: ZEND_INI_SCANNER_NORMAL, ZEND_INI_SCANNER_RAW, ZEND_INI_SCANNER_TYPED */ int scanner_mode; diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y index 5f788f152fb6a..748ccd2235a6d 100644 --- a/Zend/zend_ini_parser.y +++ b/Zend/zend_ini_parser.y @@ -205,7 +205,7 @@ static ZEND_COLD void ini_error(const char *msg) error_buf_len = 128 + (int)strlen(msg) + (int)strlen(currently_parsed_filename); /* should be more than enough */ error_buf = (char *) emalloc(error_buf_len); - sprintf(error_buf, "%s in %s on line %d\n", msg, currently_parsed_filename, zend_ini_scanner_get_lineno()); + sprintf(error_buf, "%s in %s on line %" PRIu32 "\n", msg, currently_parsed_filename, zend_ini_scanner_get_lineno()); } else { error_buf = estrdup("Invalid configuration directive\n"); } diff --git a/Zend/zend_ini_scanner.h b/Zend/zend_ini_scanner.h index 62546413c7cb2..9a6c84fce4292 100644 --- a/Zend/zend_ini_scanner.h +++ b/Zend/zend_ini_scanner.h @@ -30,7 +30,7 @@ typedef struct _zend_file_handle zend_file_handle; #define ZEND_INI_SCANNER_TYPED 2 /* Typed mode. */ BEGIN_EXTERN_C() -ZEND_COLD int zend_ini_scanner_get_lineno(void); +ZEND_COLD uint32_t zend_ini_scanner_get_lineno(void); ZEND_COLD const char *zend_ini_scanner_get_filename(void); zend_result zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode); zend_result zend_ini_prepare_string_for_scanning(const char *str, int scanner_mode); diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l index b87f4e33cc8f8..d3f71ba8bc340 100644 --- a/Zend/zend_ini_scanner.l +++ b/Zend/zend_ini_scanner.l @@ -230,7 +230,7 @@ void shutdown_ini_scanner(void) /* }}} */ /* {{{ zend_ini_scanner_get_lineno() */ -ZEND_COLD int zend_ini_scanner_get_lineno(void) +ZEND_COLD uint32_t zend_ini_scanner_get_lineno(void) { return SCNG(lineno); } diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 17676e8edea48..7514a1ddef82f 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -2006,7 +2006,6 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st ZEND_API void zend_class_init_statics(zend_class_entry *class_type) /* {{{ */ { - int i; zval *p; if (class_type->default_static_members_count && !CE_STATIC_MEMBERS(class_type)) { @@ -2015,7 +2014,7 @@ ZEND_API void zend_class_init_statics(zend_class_entry *class_type) /* {{{ */ } ZEND_MAP_PTR_SET(class_type->static_members_table, emalloc(sizeof(zval) * class_type->default_static_members_count)); - for (i = 0; i < class_type->default_static_members_count; i++) { + for (uint32_t i = 0; i < class_type->default_static_members_count; i++) { p = &class_type->default_static_members_table[i]; if (Z_TYPE_P(p) == IS_INDIRECT) { zval *q = &CE_STATIC_MEMBERS(class_type->parent)[i]; diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 3c3065e156871..34e58639c64cd 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -8006,7 +8006,7 @@ ZEND_VM_HANDLER(105, ZEND_TICKS, ANY, ANY, NUM) { USE_OPLINE - if ((uint32_t)++EG(ticks_count) >= opline->extended_value) { + if (++EG(ticks_count) >= opline->extended_value) { EG(ticks_count) = 0; if (zend_ticks_function) { SAVE_OPLINE(); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 50870ce463de3..cc8bc51a7f4ea 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -3278,7 +3278,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_TICKS_SPEC_HA { USE_OPLINE - if ((uint32_t)++EG(ticks_count) >= opline->extended_value) { + if (++EG(ticks_count) >= opline->extended_value) { EG(ticks_count) = 0; if (zend_ticks_function) { SAVE_OPLINE(); @@ -58798,7 +58798,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_TICKS_SPEC_TAILCAL { USE_OPLINE - if ((uint32_t)++EG(ticks_count) >= opline->extended_value) { + if (++EG(ticks_count) >= opline->extended_value) { EG(ticks_count) = 0; if (zend_ticks_function) { SAVE_OPLINE(); diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index e1187b045b13e..ef69cceb0250b 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -967,12 +967,11 @@ zend_class_entry *zend_persist_class_entry(zend_class_entry *orig_ce) } } if (ce->default_static_members_table) { - int i; ce->default_static_members_table = zend_shared_memdup_free(ce->default_static_members_table, sizeof(zval) * ce->default_static_members_count); /* Persist only static properties in this class. * Static properties from parent classes will be handled in class_copy_ctor and are marked with IS_INDIRECT */ - for (i = 0; i < ce->default_static_members_count; i++) { + for (uint32_t i = 0; i < ce->default_static_members_count; i++) { if (Z_TYPE(ce->default_static_members_table[i]) != IS_INDIRECT) { zend_persist_zval(&ce->default_static_members_table[i]); } diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c index 3c763d239e5ff..c638d66619d0f 100644 --- a/ext/opcache/zend_persist_calc.c +++ b/ext/opcache/zend_persist_calc.c @@ -479,10 +479,8 @@ void zend_persist_class_entry_calc(zend_class_entry *ce) } } if (ce->default_static_members_table) { - int i; - ADD_SIZE(sizeof(zval) * ce->default_static_members_count); - for (i = 0; i < ce->default_static_members_count; i++) { + for (uint32_t i = 0; i < ce->default_static_members_count; i++) { if (Z_TYPE(ce->default_static_members_table[i]) != IS_INDIRECT) { zend_persist_zval_calc(&ce->default_static_members_table[i]); } diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 8a41ae99199fd..15cdddb21af4f 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -1647,6 +1647,12 @@ static zend_result phar_open_from_fp(php_stream* fp, char *fname, size_t fname_l if (!PHAR_G(has_zlib)) { MAPPHAR_ALLOC_FAIL("unable to decompress gzipped phar archive \"%s\" to temporary file, enable zlib extension in php.ini") } + + /* entire file is gzip-compressed, uncompress to temporary file */ + if (!(temp = php_stream_fopen_tmpfile())) { + MAPPHAR_ALLOC_FAIL("unable to create temporary file for decompression of gzipped phar archive \"%s\"") + } + array_init(&filterparams); /* this is defined in zlib's zconf.h */ #ifndef MAX_WBITS @@ -1654,11 +1660,6 @@ static zend_result phar_open_from_fp(php_stream* fp, char *fname, size_t fname_l #endif add_assoc_long_ex(&filterparams, "window", sizeof("window") - 1, MAX_WBITS + 32); - /* entire file is gzip-compressed, uncompress to temporary file */ - if (!(temp = php_stream_fopen_tmpfile())) { - MAPPHAR_ALLOC_FAIL("unable to create temporary file for decompression of gzipped phar archive \"%s\"") - } - php_stream_rewind(fp); filter = php_stream_filter_create("zlib.inflate", &filterparams, php_stream_is_persistent(fp)); diff --git a/ext/phar/zip.c b/ext/phar/zip.c index 5abbc49d3c2ce..e38708e1337da 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -1259,6 +1259,7 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) void phar_zip_flush(phar_archive_data *phar, z return; } if (phar->alias_len != php_stream_write(entry.fp, phar->alias, phar->alias_len)) { + php_stream_close(entry.fp); spprintf(error, 0, "unable to set alias in zip-based phar \"%s\"", phar->fname); return; }