Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
399a6b2b
Commit
399a6b2b
authored
Apr 09, 2020
by
antirez
Browse files
incrRefCount(): abort on statically allocated object.
parent
45187252
Changes
2
Show whitespace changes
Inline
Side-by-side
src/object.c
View file @
399a6b2b
...
...
@@ -347,7 +347,15 @@ void freeStreamObject(robj *o) {
}
void
incrRefCount
(
robj
*
o
)
{
if
(
o
->
refcount
!=
OBJ_SHARED_REFCOUNT
)
o
->
refcount
++
;
if
(
o
->
refcount
<
OBJ_FIRST_SPECIAL_REFCOUNT
)
{
o
->
refcount
++
;
}
else
{
if
(
o
->
refcount
==
OBJ_SHARED_REFCOUNT
)
{
/* Nothing to do: this refcount is immutable. */
}
else
if
(
o
->
refcount
==
OBJ_STATIC_REFCOUNT
)
{
serverPanic
(
"You tried to retain an object allocated in the stack"
);
}
}
}
void
decrRefCount
(
robj
*
o
)
{
...
...
src/server.h
View file @
399a6b2b
...
...
@@ -597,7 +597,9 @@ typedef struct RedisModuleDigest {
#define LRU_CLOCK_MAX ((1<<LRU_BITS)-1)
/* Max value of obj->lru */
#define LRU_CLOCK_RESOLUTION 1000
/* LRU clock resolution in ms */
#define OBJ_SHARED_REFCOUNT INT_MAX
#define OBJ_SHARED_REFCOUNT INT_MAX
/* Global object never destroyed. */
#define OBJ_STATIC_REFCOUNT (INT_MAX-1)
/* Object allocated in the stack. */
#define OBJ_FIRST_SPECIAL_REFCOUNT OBJ_STATIC_REFCOUNT
typedef
struct
redisObject
{
unsigned
type
:
4
;
unsigned
encoding
:
4
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment