Kouhei Sutou
null+****@clear*****
Thu Mar 16 10:23:15 JST 2017
Kouhei Sutou 2017-03-16 10:23:15 +0900 (Thu, 16 Mar 2017) New Revision: 79f0d262fc3daa95c004492d69ec6891b18958e4 https://github.com/groonga/groonga/commit/79f0d262fc3daa95c004492d69ec6891b18958e4 Message: mrb_table_apply_expr: validate arguments Modified files: lib/table.c Modified: lib/table.c (+27 -3) =================================================================== --- lib/table.c 2017-03-16 10:13:31 +0900 (f47be3d) +++ lib/table.c 2017-03-16 10:23:15 +0900 (8399502) @@ -21,14 +21,38 @@ grn_rc grn_table_apply_expr(grn_ctx *ctx, - grn_obj *table, - grn_obj *output_column, - grn_obj *expr) + grn_obj *table, + grn_obj *output_column, + grn_obj *expr) { grn_obj *record; GRN_API_ENTER; + if (!grn_obj_is_data_column(ctx, output_column)) { + grn_obj inspected; + GRN_TEXT_INIT(&inspected, 0); + grn_inspect(ctx, &inspected, output_column); + ERR(GRN_INVALID_ARGUMENT, + "[table][apply-expr] output column isn't data column: %.*s", + (int)GRN_TEXT_LEN(&inspected), + GRN_TEXT_VALUE(&inspected)); + GRN_OBJ_FIN(ctx, &inspected); + GRN_API_RETURN(ctx->rc); + } + + if (!grn_obj_is_expr(ctx, expr)) { + grn_obj inspected; + GRN_TEXT_INIT(&inspected, 0); + grn_inspect(ctx, &inspected, expr); + ERR(GRN_INVALID_ARGUMENT, + "[table][apply-expr] expr is invalid: %.*s", + (int)GRN_TEXT_LEN(&inspected), + GRN_TEXT_VALUE(&inspected)); + GRN_OBJ_FIN(ctx, &inspected); + GRN_API_RETURN(ctx->rc); + } + record = grn_expr_get_var_by_offset(ctx, expr, 0); GRN_TABLE_EACH_BEGIN_FLAGS(ctx, table, cursor, id, GRN_CURSOR_BY_ID) { grn_obj *value; -------------- next part -------------- HTML����������������������������...Download