Skip to content

Commit 1b8d4f7

Browse files
dictcpdick9gag
authored andcommitted
correct the compression_factor calculation
1 parent 2af9b61 commit 1b8d4f7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

php_memcached.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ static int php_memc_list_entry(void) {
108108
#define MEMC_VAL_COMPRESSION_ZLIB (1<<1)
109109
#define MEMC_VAL_COMPRESSION_FASTLZ (1<<2)
110110

111-
#define MEMC_VAL_GET_FLAGS(internal_flags) ((internal_flags & MEMC_MASK_INTERNAL) >> 4)
112-
#define MEMC_VAL_SET_FLAG(internal_flags, internal_flag) ((internal_flags) |= ((internal_flag << 4) & MEMC_MASK_INTERNAL))
113-
#define MEMC_VAL_HAS_FLAG(internal_flags, internal_flag) ((MEMC_VAL_GET_FLAGS(internal_flags) & internal_flag) == internal_flag)
114-
#define MEMC_VAL_DEL_FLAG(internal_flags, internal_flag) internal_flags &= ~((internal_flag << 4) & MEMC_MASK_INTERNAL)
111+
#define MEMC_VAL_GET_FLAGS(internal_flags) (((internal_flags) & MEMC_MASK_INTERNAL) >> 4)
112+
#define MEMC_VAL_SET_FLAG(internal_flags, internal_flag) ((internal_flags) |= (((internal_flag) << 4) & MEMC_MASK_INTERNAL))
113+
#define MEMC_VAL_HAS_FLAG(internal_flags, internal_flag) ((MEMC_VAL_GET_FLAGS(internal_flags) & (internal_flag)) == (internal_flag))
114+
#define MEMC_VAL_DEL_FLAG(internal_flags, internal_flag) (internal_flags &= (~(((internal_flag) << 4) & MEMC_MASK_INTERNAL)))
115115

116116
/****************************************
117117
User-defined flags
@@ -867,7 +867,7 @@ zend_bool s_compress_value (php_memc_compression_type compression_type, zend_str
867867
}
868868

869869
/* This means the value was too small to be compressed, still a success */
870-
if (compressed_size > (ZSTR_LEN(payload) * MEMC_G(compression_factor))) {
870+
if (ZSTR_LEN(payload) < (compressed_size * MEMC_G(compression_factor))) {
871871
efree (buffer);
872872
return 1;
873873
}

0 commit comments

Comments
 (0)