Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Zend/zend_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2432,6 +2432,7 @@ ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent)
}
#if ZEND_MM_STAT
heap->size = 0;
heap->real_size = 0;
#endif
}

Expand Down Expand Up @@ -2999,6 +3000,7 @@ static void *tracked_malloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC
tracked_add(heap, ptr, size);
#if ZEND_MM_STAT
heap->size += size;
heap->real_size = heap->size;
#endif
return ptr;
}
Expand All @@ -3012,6 +3014,7 @@ static void tracked_free(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) {
zval *size_zv = tracked_get_size_zv(heap, ptr);
#if ZEND_MM_STAT
heap->size -= Z_LVAL_P(size_zv);
heap->real_size = heap->size;
#endif
zend_hash_del_bucket(heap->tracked_allocs, (Bucket *) size_zv);
free(ptr);
Expand Down Expand Up @@ -3039,6 +3042,7 @@ static void *tracked_realloc(void *ptr, size_t new_size ZEND_FILE_LINE_DC ZEND_F
tracked_add(heap, ptr, new_size);
#if ZEND_MM_STAT
heap->size += new_size - old_size;
heap->real_size = heap->size;
#endif
return ptr;
}
Expand Down
69 changes: 39 additions & 30 deletions ext/bcmath/libbcmath/src/compare.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,25 @@
than N2 and +1 if N1 is greater than N2. If USE_SIGN is false, just
compare the magnitudes. */

static inline bcmath_compare_result bc_compare_get_result_val(bool left_abs_greater, bool use_sign, sign left_sign)
{
if (left_abs_greater) {
/* Magnitude of left > right. */
if (!use_sign || left_sign == PLUS) {
return BCMATH_LEFT_GREATER;
} else {
return BCMATH_RIGHT_GREATER;
}
} else {
/* Magnitude of left < right. */
if (!use_sign || left_sign == PLUS) {
return BCMATH_RIGHT_GREATER;
} else {
return BCMATH_LEFT_GREATER;
}
}
}

bcmath_compare_result _bc_do_compare(bc_num n1, bc_num n2, size_t scale, bool use_sign)
{
/* First, compare signs. */
Expand Down Expand Up @@ -66,21 +85,7 @@ bcmath_compare_result _bc_do_compare(bc_num n1, bc_num n2, size_t scale, bool us

/* Now compare the magnitude. */
if (n1->n_len != n2->n_len) {
if (n1->n_len > n2->n_len) {
/* Magnitude of n1 > n2. */
if (!use_sign || n1->n_sign == PLUS) {
return BCMATH_LEFT_GREATER;
} else {
return BCMATH_RIGHT_GREATER;
}
} else {
/* Magnitude of n1 < n2. */
if (!use_sign || n1->n_sign == PLUS) {
return BCMATH_RIGHT_GREATER;
} else {
return BCMATH_LEFT_GREATER;
}
}
return bc_compare_get_result_val(n1->n_len > n2->n_len, use_sign, n1->n_sign);
}

size_t n1_scale = MIN(n1->n_scale, scale);
Expand All @@ -92,28 +97,32 @@ bcmath_compare_result _bc_do_compare(bc_num n1, bc_num n2, size_t scale, bool us
const char *n1ptr = n1->n_value;
const char *n2ptr = n2->n_value;

while (count >= sizeof(BC_VECTOR)) {
BC_VECTOR n1bytes;
BC_VECTOR n2bytes;
memcpy(&n1bytes, n1ptr, sizeof(BC_VECTOR));
memcpy(&n2bytes, n2ptr, sizeof(BC_VECTOR));

if (n1bytes != n2bytes) {
#if BC_LITTLE_ENDIAN
n1bytes = BC_BSWAP(n1bytes);
n2bytes = BC_BSWAP(n2bytes);
#endif
return bc_compare_get_result_val(n1bytes > n2bytes, use_sign, n1->n_sign);
}
count -= sizeof(BC_VECTOR);
n1ptr += sizeof(BC_VECTOR);
n2ptr += sizeof(BC_VECTOR);
}

while ((count > 0) && (*n1ptr == *n2ptr)) {
n1ptr++;
n2ptr++;
count--;
}

if (count != 0) {
if (*n1ptr > *n2ptr) {
/* Magnitude of n1 > n2. */
if (!use_sign || n1->n_sign == PLUS) {
return BCMATH_LEFT_GREATER;
} else {
return BCMATH_RIGHT_GREATER;
}
} else {
/* Magnitude of n1 < n2. */
if (!use_sign || n1->n_sign == PLUS) {
return BCMATH_RIGHT_GREATER;
} else {
return BCMATH_LEFT_GREATER;
}
}
return bc_compare_get_result_val(*n1ptr > *n2ptr, use_sign, n1->n_sign);
}

/* They are equal up to the last part of the equal part of the fraction. */
Expand Down
2 changes: 1 addition & 1 deletion ext/dom/html_document.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ static bool dom_parse_decode_encode_finish(

static bool check_options_validity(uint32_t arg_num, zend_long options)
{
const zend_long VALID_OPTIONS = XML_PARSE_NOERROR | XML_PARSE_COMPACT | HTML_PARSE_NOIMPLIED | DOM_HTML_NO_DEFAULT_NS;
const zend_long VALID_OPTIONS = HTML_PARSE_NOERROR | HTML_PARSE_COMPACT | HTML_PARSE_NOIMPLIED | DOM_HTML_NO_DEFAULT_NS;
if ((options & ~VALID_OPTIONS) != 0) {
zend_argument_value_error(arg_num, "contains invalid flags (allowed flags: "
"LIBXML_NOERROR, "
Expand Down
Loading