[Groonga-commit] groonga/groonga [master] Fix a crash bug

Zurück zum Archiv-Index

Kouhei Sutou null+****@clear*****
Thu Jan 17 14:35:09 JST 2013


Kouhei Sutou	2013-01-17 14:35:09 +0900 (Thu, 17 Jan 2013)

  New Revision: 0ad904d99b38a49d228cdc3732fd7cea3e5ed257
  https://github.com/groonga/groonga/commit/0ad904d99b38a49d228cdc3732fd7cea3e5ed257

  Log:
    Fix a crash bug
    
    It is caused when not initialized vector value is used as condition.

  Added files:
    test/command/suite/select/filter/vector/not_initialized.expected
    test/command/suite/select/filter/vector/not_initialized.test
  Modified files:
    lib/expr.c

  Modified: lib/expr.c (+6 -4)
===================================================================
--- lib/expr.c    2013-01-17 13:43:24 +0900 (a09e60f)
+++ lib/expr.c    2013-01-17 14:35:09 +0900 (26b547c)
@@ -2716,10 +2716,12 @@ grn_expr_exec(grn_ctx *ctx, grn_obj *expr, int nargs)
             if (size == GRN_OBJ_GET_VALUE_IMD) {
               GRN_RECORD_SET(ctx, res, (uintptr_t)value);
             } else {
-              if (res->header.type == GRN_VECTOR) {
-                grn_vector_decode(ctx, res, value, size);
-              } else {
-                grn_bulk_write_from(ctx, res, value, 0, size);
+              if (value) {
+                if (res->header.type == GRN_VECTOR) {
+                  grn_vector_decode(ctx, res, value, size);
+                } else {
+                  grn_bulk_write_from(ctx, res, value, 0, size);
+                }
               }
             }
             code++;

  Added: test/command/suite/select/filter/vector/not_initialized.expected (+54 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/vector/not_initialized.expected    2013-01-17 14:35:09 +0900 (6cea10a)
@@ -0,0 +1,54 @@
+table_create Sites TABLE_PAT_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Sites tags COLUMN_VECTOR ShortText
+[[0,0.0,0.0],true]
+load --table Sites
+[
+["_key"],
+["groonga.org"],
+["razil.jp"]
+]
+[[0,0.0,0.0],2]
+select Sites --filter 'tags == ""'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        2
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "tags",
+          "ShortText"
+        ]
+      ],
+      [
+        1,
+        "groonga.org",
+        [
+
+        ]
+      ],
+      [
+        2,
+        "razil.jp",
+        [
+
+        ]
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/filter/vector/not_initialized.test (+11 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/vector/not_initialized.test    2013-01-17 14:35:09 +0900 (c1a285e)
@@ -0,0 +1,11 @@
+table_create Sites TABLE_PAT_KEY ShortText
+column_create Sites tags COLUMN_VECTOR ShortText
+
+load --table Sites
+[
+["_key"],
+["groonga.org"],
+["razil.jp"]
+]
+
+select Sites --filter 'tags == ""'
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index