Fix applying zero offset to null pointer when creating moduleFreeContextReusedClient (#7323)
Before this fix we where attempting to select a db before creating db the DB, see: #7323 This issue doesn't seem to have any implications, since the selected DB index is 0, the db pointer remains NULL, and will later be correctly set before using this dummy client for the first time. As we know, we call 'moduleInitModulesSystem()' before 'initServer()'. We will allocate memory for server.db in 'initServer', but we call 'createClient()' that will call 'selectDb()' in 'moduleInitModulesSystem()', before the databases where created. Instead, we should call 'createClient()' for moduleFreeContextReusedClient after 'initServer()'.
This commit is contained in:
parent
b118502a05
commit
1ef014ee6b
13
src/module.c
13
src/module.c
@ -7249,6 +7249,16 @@ int moduleRegisterApi(const char *funcname, void *funcptr) {
|
|||||||
/* Global initialization at Redis startup. */
|
/* Global initialization at Redis startup. */
|
||||||
void moduleRegisterCoreAPI(void);
|
void moduleRegisterCoreAPI(void);
|
||||||
|
|
||||||
|
/* Some steps in module initialization need to be done last after server
|
||||||
|
* initialization.
|
||||||
|
* For example, selectDb() in createClient() requires that server.db has
|
||||||
|
* been initialized, see #7323. */
|
||||||
|
void moduleInitModulesSystemLast(void) {
|
||||||
|
moduleFreeContextReusedClient = createClient(NULL);
|
||||||
|
moduleFreeContextReusedClient->flags |= CLIENT_MODULE;
|
||||||
|
moduleFreeContextReusedClient->user = NULL; /* root user. */
|
||||||
|
}
|
||||||
|
|
||||||
void moduleInitModulesSystem(void) {
|
void moduleInitModulesSystem(void) {
|
||||||
moduleUnblockedClients = listCreate();
|
moduleUnblockedClients = listCreate();
|
||||||
server.loadmodule_queue = listCreate();
|
server.loadmodule_queue = listCreate();
|
||||||
@ -7256,9 +7266,6 @@ void moduleInitModulesSystem(void) {
|
|||||||
|
|
||||||
/* Set up the keyspace notification susbscriber list and static client */
|
/* Set up the keyspace notification susbscriber list and static client */
|
||||||
moduleKeyspaceSubscribers = listCreate();
|
moduleKeyspaceSubscribers = listCreate();
|
||||||
moduleFreeContextReusedClient = createClient(NULL);
|
|
||||||
moduleFreeContextReusedClient->flags |= CLIENT_MODULE;
|
|
||||||
moduleFreeContextReusedClient->user = NULL; /* root user. */
|
|
||||||
|
|
||||||
/* Set up filter list */
|
/* Set up filter list */
|
||||||
moduleCommandFilters = listCreate();
|
moduleCommandFilters = listCreate();
|
||||||
|
@ -5205,6 +5205,7 @@ int main(int argc, char **argv) {
|
|||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
linuxMemoryWarnings();
|
linuxMemoryWarnings();
|
||||||
#endif
|
#endif
|
||||||
|
moduleInitModulesSystemLast();
|
||||||
moduleLoadFromQueue();
|
moduleLoadFromQueue();
|
||||||
ACLLoadUsersAtStartup();
|
ACLLoadUsersAtStartup();
|
||||||
InitServerLast();
|
InitServerLast();
|
||||||
|
@ -1572,6 +1572,7 @@ extern dictType modulesDictType;
|
|||||||
|
|
||||||
/* Modules */
|
/* Modules */
|
||||||
void moduleInitModulesSystem(void);
|
void moduleInitModulesSystem(void);
|
||||||
|
void moduleInitModulesSystemLast(void);
|
||||||
int moduleLoad(const char *path, void **argv, int argc);
|
int moduleLoad(const char *path, void **argv, int argc);
|
||||||
void moduleLoadFromQueue(void);
|
void moduleLoadFromQueue(void);
|
||||||
int *moduleGetCommandKeysViaAPI(struct redisCommand *cmd, robj **argv, int argc, int *numkeys);
|
int *moduleGetCommandKeysViaAPI(struct redisCommand *cmd, robj **argv, int argc, int *numkeys);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user