8000 Cleaner handling of large values on 32-bits. · jrtkcoder/phpredis@f8f552e · GitHub
[go: up one dir, main page]

Skip to content

Commit f8f552e

Browse files
committed
Cleaner handling of large values on 32-bits.
Tested on 32-bits, addresses GitHub issue phpredis#174.
1 parent 74675fb commit f8f552e

File tree

3 files changed

+3
-28
lines changed

3 files changed

+3
-28
lines changed

common.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,6 @@
44
#ifndef REDIS_COMMON_H
55
#define REDIS_COMMON_H
66

7-
/* Check windows */
8-
#if _WIN32 || _WIN64
9-
#if _WIN64
10-
#define PHP64
11-
#else
12-
#define PHP32
13-
#endif
14-
#endif
15-
16-
/* Check GCC and Clang */
17-
#if __GNUC__
18-
#if __x86_64__ || __ppc64__
19-
#define PHP64
20-
#else
21-
#define PHP32
22-
#endif
23-
#endif
24-
257
#define redis_sock_name "Redis Socket Buffer"
268
#define REDIS_SOCK_STATUS_FAILED 0
279
#define REDIS_SOCK_STATUS_DISCONNECTED 1

library.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,16 +550,16 @@ PHPAPI void redis_long_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_s
550550
}
551551

552552
if(response[0] == ':') {
553-
long ret = atol(response + 1);
553+
long long ret = atoll(response + 1);
554554
IF_MULTI_OR_PIPELINE() {
555-
if(ret > (long)LONG_MAX) { /* overflow */
555+
if(ret > LONG_MAX) { /* overflow */
556556
add_next_index_stringl(z_tab, response+1, response_len-1, 1);
557557
} else {
558558
efree(response);
559559
add_next_index_long(z_tab, (long)ret);
560560
}
561561
} else {
562-
if(ret > (long)LONG_MAX) { /* overflow */
562+
if(ret > LONG_MAX) { /* overflow */
563563
RETURN_STRINGL(response+1, response_len-1, 1);
564564
} else {
565565
efree(response);

redis.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3283,17 +3283,10 @@ PHPAPI void generic_ttl(INTERNAL_FUNCTION_PARAMETERS, char *keyword) {
32833283
if(key_free) efree(key);
32843284

32853285
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
3286-
#ifdef PHP64
32873286
IF_ATOMIC() {
32883287
redis_long_response(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, NULL);
32893288
}
32903289
REDIS_PROCESS_RESPONSE(redis_long_response);
3291-
#else
3292-
IF_ATOMIC() {
3293-
redis_bulk_double_response(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, NULL);
3294-
}
3295-
REDIS_PROCESS_RESPONSE(redis_bulk_double_response);
3296-
#endif
32973290
}
32983291

32993292
/* {{{ proto long Redis::ttl(string key)

0 commit comments

Comments
 (0)
0