diff --git a/src/config.c b/src/config.c index 8b5a6f218..05d0257cc 100644 --- a/src/config.c +++ b/src/config.c @@ -155,13 +155,13 @@ void resetServerSaveParams(void) { void queueLoadModule(sds path, sds *argv, int argc) { - struct loadmodule *loadmod = zmalloc(sizeof(struct loadmodule)+sizeof(sds)*argc); + struct loadmodule *loadmod = zmalloc(sizeof(struct loadmodule)+sizeof(robj*)*argc); int i; loadmod->path = sdsnew(path); loadmod->argc = argc; for (i = 0; i < argc; i++) { - loadmod->argv[i] = sdsnew(argv[i]); + loadmod->argv[i] = createStringObject(argv[i],sdslen(argv[i])); } listAddNodeTail(server.loadmodule_queue,loadmod); } diff --git a/src/module.c b/src/module.c index 27e041b50..8f45cf48d 100644 --- a/src/module.c +++ b/src/module.c @@ -3011,16 +3011,12 @@ void moduleCommand(client *c) { char *subcmd = c->argv[1]->ptr; if (!strcasecmp(subcmd,"load") && c->argc >= 3) { - sds *argv = NULL; + robj **argv = NULL; int argc = 0; - int i; if (c->argc > 3) { argc = c->argc - 3; - argv = zmalloc(sizeof(sds)*argc); - for (i=0; iargv[i+3]->ptr; - } + argv = &c->argv[3]; } if (moduleLoad(c->argv[2]->ptr,(void **)argv,argc) == C_OK) @@ -3028,8 +3024,6 @@ void moduleCommand(client *c) { else addReplyError(c, "Error loading the extension. Please check the server logs."); - if (argv) - zfree(argv); } else if (!strcasecmp(subcmd,"unload") && c->argc == 3) { if (moduleUnload(c->argv[2]->ptr) == C_OK) addReply(c,shared.ok); diff --git a/src/server.h b/src/server.h index a16d1a4ec..82bee10a8 100644 --- a/src/server.h +++ b/src/server.h @@ -686,7 +686,7 @@ struct saveparam { struct loadmodule { sds path; int argc; - sds argv[]; + robj *argv[]; }; struct sharedObjectsStruct {