[Groonga-commit] pgroonga/pgroonga at 466c0fc [master] Fix a bug that NULL value for jsonb causes crash

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jun 21 23:50:59 JST 2017


Kouhei Sutou	2017-06-21 23:50:59 +0900 (Wed, 21 Jun 2017)

  New Revision: 466c0fc99c0e0c871511d375f54e2feb2fb9d027
  https://github.com/pgroonga/pgroonga/commit/466c0fc99c0e0c871511d375f54e2feb2fb9d027

  Message:
    Fix a bug that NULL value for jsonb causes crash
    
    [groonga-dev:04382]
    
    Reported by Hirokazu Matsuo. Thanks!!!

  Added files:
    expected/jsonb/null/insert.out
    expected/jsonb/null/select.out
    sql/jsonb/null/insert.sql
    sql/jsonb/null/select.sql
  Modified files:
    src/pgrn-jsonb.c

  Added: expected/jsonb/null/insert.out (+13 -0) 100644
===================================================================
--- /dev/null
+++ expected/jsonb/null/insert.out    2017-06-21 23:50:59 +0900 (f078b2c)
@@ -0,0 +1,13 @@
+CREATE TABLE logs (
+  record jsonb
+);
+CREATE INDEX pgroonga_index ON logs
+  USING pgroonga (record pgroonga.jsonb_ops_v2);
+INSERT INTO logs VALUES (NULL);
+SELECT * FROM logs;
+ record 
+--------
+ 
+(1 row)
+
+DROP TABLE logs;

  Added: expected/jsonb/null/select.out (+14 -0) 100644
===================================================================
--- /dev/null
+++ expected/jsonb/null/select.out    2017-06-21 23:50:59 +0900 (3de2eb8)
@@ -0,0 +1,14 @@
+CREATE TABLE logs (
+  record jsonb
+);
+CREATE INDEX pgroonga_index ON logs
+  USING pgroonga (record pgroonga.jsonb_ops_v2);
+INSERT INTO logs VALUES ('{}');
+SELECT *
+  FROM logs
+ WHERE record &@ null;
+ record 
+--------
+(0 rows)
+
+DROP TABLE logs;

  Added: sql/jsonb/null/insert.sql (+12 -0) 100644
===================================================================
--- /dev/null
+++ sql/jsonb/null/insert.sql    2017-06-21 23:50:59 +0900 (18bc802)
@@ -0,0 +1,12 @@
+CREATE TABLE logs (
+  record jsonb
+);
+
+CREATE INDEX pgroonga_index ON logs
+  USING pgroonga (record pgroonga.jsonb_ops_v2);
+
+INSERT INTO logs VALUES (NULL);
+
+SELECT * FROM logs;
+
+DROP TABLE logs;

  Added: sql/jsonb/null/select.sql (+14 -0) 100644
===================================================================
--- /dev/null
+++ sql/jsonb/null/select.sql    2017-06-21 23:50:59 +0900 (c024a42)
@@ -0,0 +1,14 @@
+CREATE TABLE logs (
+  record jsonb
+);
+
+CREATE INDEX pgroonga_index ON logs
+  USING pgroonga (record pgroonga.jsonb_ops_v2);
+
+INSERT INTO logs VALUES ('{}');
+
+SELECT *
+  FROM logs
+ WHERE record &@ null;
+
+DROP TABLE logs;

  Modified: src/pgrn-jsonb.c (+3 -0)
===================================================================
--- src/pgrn-jsonb.c    2017-06-20 13:58:53 +0900 (66e7a05)
+++ src/pgrn-jsonb.c    2017-06-21 23:50:59 +0900 (3869cc7)
@@ -1329,6 +1329,9 @@ PGrnJSONBInsert(Relation index,
 	unsigned int nthValue = 0;
 	Jsonb *jsonb;
 
+	if (isnull[nthValue])
+		return recordSize;
+
 	data.index = index;
 	data.pathsTable  = PGrnJSONBLookupPathsTable(index, nthValue, ERROR);
 	data.valuesTable = PGrnJSONBLookupValuesTable(index, nthValue, ERROR);
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index