forked from M-Labs/artiq
runtime: fix sloppy memory management in cache_put.
This commit is contained in:
parent
9ffa8cbb11
commit
739568fcb8
|
@ -1027,7 +1027,6 @@ static int process_kmsg(struct msg_base *umsg)
|
||||||
struct cache_row *row = NULL;
|
struct cache_row *row = NULL;
|
||||||
for(struct cache_row *iter = cache; iter; iter = iter->next) {
|
for(struct cache_row *iter = cache; iter; iter = iter->next) {
|
||||||
if(!strcmp(iter->key, request->key)) {
|
if(!strcmp(iter->key, request->key)) {
|
||||||
free(iter->elements);
|
|
||||||
row = iter;
|
row = iter;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1042,11 +1041,14 @@ static int process_kmsg(struct msg_base *umsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!row->borrowed) {
|
if(!row->borrowed) {
|
||||||
if(request->length != 0) {
|
|
||||||
row->length = request->length;
|
row->length = request->length;
|
||||||
|
if(row->length != 0) {
|
||||||
row->elements = calloc(row->length, sizeof(int32_t));
|
row->elements = calloc(row->length, sizeof(int32_t));
|
||||||
memcpy(row->elements, request->elements,
|
memcpy(row->elements, request->elements,
|
||||||
sizeof(int32_t) * row->length);
|
sizeof(int32_t) * row->length);
|
||||||
|
} else {
|
||||||
|
free(row->elements);
|
||||||
|
row->elements = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.succeeded = 1;
|
reply.succeeded = 1;
|
||||||
|
|
Loading…
Reference in New Issue