[Groonga-commit] groonga/groonga [master] fix crash bug for "--filter column @ column". fixes #1047

Back to archive index

null+****@clear***** null+****@clear*****
2011年 8月 15日 (月) 23:14:36 JST


Kouhei Sutou	2011-08-15 14:14:36 +0000 (Mon, 15 Aug 2011)

  New Revision: 1fced29b1deff7a85b02e6c99fb3fe122184be3b

  Log:
    fix crash bug for "--filter column @ column". fixes #1047

  Modified files:
    lib/expr.c
    test/unit/core/test-command-select-filter-invalid.c

  Modified: lib/expr.c (+17 -1)
===================================================================
--- lib/expr.c    2011-08-15 05:37:24 +0000 (c33a58c)
+++ lib/expr.c    2011-08-15 14:14:36 +0000 (97320b4)
@@ -3737,7 +3737,23 @@ scan_info_build(grn_ctx *ctx, grn_obj *expr, int *n,
         }
         break;
       case SCAN_COL1 :
-        si->args[si->nargs - 1] = NULL;
+        {
+          int j;
+          grn_obj inspected;
+          GRN_TEXT_INIT(&inspected, 0);
+          GRN_TEXT_PUTS(ctx, &inspected, "<");
+          grn_inspect_name(ctx, &inspected, c->value);
+          GRN_TEXT_PUTS(ctx, &inspected, ">: <");
+          grn_inspect(ctx, &inspected, expr);
+          GRN_TEXT_PUTS(ctx, &inspected, ">");
+          ERR(GRN_INVALID_ARGUMENT,
+              "invalid expression: can't use column as a value: %.*s",
+              GRN_TEXT_LEN(&inspected), GRN_TEXT_VALUE(&inspected));
+          GRN_OBJ_FIN(ctx, &inspected);
+          for (j = 0; j < i; j++) { SI_FREE(sis[j]); }
+          GRN_FREE(sis);
+          return NULL;
+        }
         stat = SCAN_COL2;
         break;
       case SCAN_COL2 :

  Modified: test/unit/core/test-command-select-filter-invalid.c (+3 -1)
===================================================================
--- test/unit/core/test-command-select-filter-invalid.c    2011-08-15 05:37:24 +0000 (3f4c41b)
+++ test/unit/core/test-command-select-filter-invalid.c    2011-08-15 14:14:36 +0000 (c155a45)
@@ -109,6 +109,8 @@ test_match_against_not_string(void)
   grn_test_assert_send_command_error(
     context,
     GRN_INVALID_ARGUMENT,
-    "invalid function: <\"groonga\">",
+    "invalid expression: can't use column as a value: "
+    "<Sites.uri>: "
+    "<noname($1:\"\"){2_key GET_VALUE,0uri GET_VALUE,0MATCH}>",
     "select Sites --filter \"_key @ uri");
 }




Groonga-commit メーリングリストの案内
Back to archive index