Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix a memory leak on loading no tokenizer indexed value
This also fixes crash by grn_token_close(NULL).

This bug was introduced in 75d4942
at Fri May 25 16:22:03 2012 +0900.
  • Loading branch information
kou committed Sep 25, 2012
1 parent 4a268e1 commit 1d06e1e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/token.c
Expand Up @@ -581,12 +581,12 @@ grn_token_close(grn_ctx *ctx, grn_token *token)
((grn_proc *)token->tokenizer)->funcs[PROC_FIN](ctx, 1, &token->table,
&token->pctx.user_data);
}
GRN_FREE(token);
return GRN_SUCCESS;
} else {
if (token->nstr) {
grn_obj_close(ctx, token->nstr);
}
GRN_FREE(token);
return GRN_SUCCESS;
} else {
return GRN_INVALID_ARGUMENT;
}
}
Expand Down
14 changes: 14 additions & 0 deletions test/function/suite/load/index/no-tokenizer.expected
@@ -0,0 +1,14 @@
table_create Users TABLE_HASH_KEY --key_type ShortText
[[0,0.0,0.0],true]
column_create Users age COLUMN_SCALAR UInt8
[[0,0.0,0.0],true]
table_create Numbers TABLE_PAT_KEY --key_type UInt8
[[0,0.0,0.0],true]
column_create Numbers age_index COLUMN_INDEX Users age
[[0,0.0,0.0],true]
load --table Users
[
["_key","age"],
["mori",41]
]
[[0,0.0,0.0],1]
11 changes: 11 additions & 0 deletions test/function/suite/load/index/no-tokenizer.test
@@ -0,0 +1,11 @@
table_create Users TABLE_HASH_KEY --key_type ShortText
column_create Users age COLUMN_SCALAR UInt8

table_create Numbers TABLE_PAT_KEY --key_type UInt8
column_create Numbers age_index COLUMN_INDEX Users age

load --table Users
[
["_key","age"],
["mori",41]
]

0 comments on commit 1d06e1e

Please sign in to comment.