Kouhei Sutou
null+****@clear*****
Wed Jan 25 23:43:16 JST 2017
Kouhei Sutou 2017-01-25 23:43:16 +0900 (Wed, 25 Jan 2017) New Revision: ed9f59ee19b5ca4c66380578ae85fe53f66c652f https://github.com/groonga/groonga/commit/ed9f59ee19b5ca4c66380578ae85fe53f66c652f Message: Fix a crash bug when tokenizer has an error It's caused when tokenizer and token filter are registered and tokenizer has an error. Modified files: lib/token_cursor.c Modified: lib/token_cursor.c (+7 -2) =================================================================== --- lib/token_cursor.c 2017-01-25 21:28:29 +0900 (95cf6da) +++ lib/token_cursor.c 2017-01-25 23:43:16 +0900 (7aff6ec) @@ -1,6 +1,6 @@ /* -*- c-basic-offset: 2 -*- */ /* - Copyright(C) 2009-2014 Brazil + Copyright(C) 2009-2017 Brazil This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -39,7 +39,7 @@ grn_token_cursor_open_initialize_token_filters(grn_ctx *ctx, return; } - token_cursor->token_filter.data = GRN_MALLOCN(void *, n_token_filters); + token_cursor->token_filter.data = GRN_CALLOC(sizeof(void *) * n_token_filters); if (!token_cursor->token_filter.data) { return; } @@ -76,6 +76,7 @@ grn_token_cursor_open(grn_ctx *ctx, grn_obj *table, token_cursor->encoding = encoding; token_cursor->tokenizer = tokenizer; token_cursor->token_filter.objects = token_filters; + token_cursor->token_filter.data = NULL; token_cursor->orig = (const unsigned char *)str; token_cursor->orig_blen = str_len; token_cursor->curr = NULL; @@ -341,6 +342,10 @@ grn_token_cursor_close_token_filters(grn_ctx *ctx, grn_obj *token_filters = token_cursor->token_filter.objects; unsigned int i, n_token_filters; + if (!token_cursor->token_filter.data) { + return; + } + if (token_filters) { n_token_filters = GRN_BULK_VSIZE(token_filters) / sizeof(grn_obj *); } else { -------------- next part -------------- HTML����������������������������... Download