Fix potential memory leak of clusterLoadConfig().
This commit is contained in:
parent
2f8134a7ff
commit
9387f7333e
@ -157,7 +157,10 @@ int clusterLoadConfig(char *filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Regular config lines have at least eight fields */
|
/* Regular config lines have at least eight fields */
|
||||||
if (argc < 8) goto fmterr;
|
if (argc < 8) {
|
||||||
|
sdsfreesplitres(argv,argc);
|
||||||
|
goto fmterr;
|
||||||
|
}
|
||||||
|
|
||||||
/* Create this node if it does not exist */
|
/* Create this node if it does not exist */
|
||||||
n = clusterLookupNode(argv[0]);
|
n = clusterLookupNode(argv[0]);
|
||||||
@ -166,7 +169,10 @@ int clusterLoadConfig(char *filename) {
|
|||||||
clusterAddNode(n);
|
clusterAddNode(n);
|
||||||
}
|
}
|
||||||
/* Address and port */
|
/* Address and port */
|
||||||
if ((p = strrchr(argv[1],':')) == NULL) goto fmterr;
|
if ((p = strrchr(argv[1],':')) == NULL) {
|
||||||
|
sdsfreesplitres(argv,argc);
|
||||||
|
goto fmterr;
|
||||||
|
}
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
memcpy(n->ip,argv[1],strlen(argv[1])+1);
|
memcpy(n->ip,argv[1],strlen(argv[1])+1);
|
||||||
char *port = p+1;
|
char *port = p+1;
|
||||||
@ -247,7 +253,10 @@ int clusterLoadConfig(char *filename) {
|
|||||||
*p = '\0';
|
*p = '\0';
|
||||||
direction = p[1]; /* Either '>' or '<' */
|
direction = p[1]; /* Either '>' or '<' */
|
||||||
slot = atoi(argv[j]+1);
|
slot = atoi(argv[j]+1);
|
||||||
if (slot < 0 || slot >= CLUSTER_SLOTS) goto fmterr;
|
if (slot < 0 || slot >= CLUSTER_SLOTS) {
|
||||||
|
sdsfreesplitres(argv,argc);
|
||||||
|
goto fmterr;
|
||||||
|
}
|
||||||
p += 3;
|
p += 3;
|
||||||
cn = clusterLookupNode(p);
|
cn = clusterLookupNode(p);
|
||||||
if (!cn) {
|
if (!cn) {
|
||||||
@ -267,8 +276,14 @@ int clusterLoadConfig(char *filename) {
|
|||||||
} else {
|
} else {
|
||||||
start = stop = atoi(argv[j]);
|
start = stop = atoi(argv[j]);
|
||||||
}
|
}
|
||||||
if (start < 0 || start >= CLUSTER_SLOTS) goto fmterr;
|
if (start < 0 || start >= CLUSTER_SLOTS) {
|
||||||
if (stop < 0 || stop >= CLUSTER_SLOTS) goto fmterr;
|
sdsfreesplitres(argv,argc);
|
||||||
|
goto fmterr;
|
||||||
|
}
|
||||||
|
if (stop < 0 || stop >= CLUSTER_SLOTS) {
|
||||||
|
sdsfreesplitres(argv,argc);
|
||||||
|
goto fmterr;
|
||||||
|
}
|
||||||
while(start <= stop) clusterAddSlot(n, start++);
|
while(start <= stop) clusterAddSlot(n, start++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user