Navigation Menu

Skip to content

Commit

Permalink
grn_proc_create: stop to re-initialize existing proc object
Browse files Browse the repository at this point in the history
It's not thread safe because proc object is shared in N threads.

It may cause memory leaks because re-initialize code doesn't free
existing values.
  • Loading branch information
kou committed Jan 5, 2015
1 parent aa2209f commit 4978fff
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/db.c
Expand Up @@ -590,12 +590,14 @@ grn_proc_create(grn_ctx *ctx, const char *name, int name_size, grn_proc_type typ
if (!added) {
db_value *vp;
if ((vp = grn_tiny_array_at(&s->values, id)) && (res = (grn_proc *)vp->ptr)) {
/* TODO: Do more robust check. */
if (res->funcs[PROC_INIT] ||
res->funcs[PROC_NEXT] ||
res->funcs[PROC_FIN]) {
ERR(GRN_INVALID_ARGUMENT, "already used name");
GRN_API_RETURN(NULL);
}
GRN_API_RETURN((grn_obj *)res);
} else {
added = 1;
}
Expand Down

0 comments on commit 4978fff

Please sign in to comment.