View Issue Details

IDProjectCategoryView StatusLast Update
0034348FPCFCLpublic2018-10-01 10:31
ReporterZoran Vučenović Assigned ToMichael Van Canneyt  
Status closedResolutionfixed 
Product Version3.2.0 
Target Version3.2.0Fixed in Version3.3.1 
Summary0034348: fpJSONDataSet -- SIGSEGV when checking if field is null
DescriptionWith fpJSONDataset, when you call IsNull method, for example JSONDataset1.Fields[0].IsNull, then:

- If the field is filled with regular value (not null), then, instead of returning False, the program crashes with Access violation.

- otherwise (when the field actually contains null), then the True value is returned regularly.
Steps To ReproduceI'm attaching the test - a simple terminal program, but created as Lazarus project. See the comments in code.
Additional InformationI tracked down the bug to TBaseJSONDataSet.GetFieldData method.
IsNull calls this method with nil buffer, and when buffer parameter is nil, the GetFieldData should return without trying to fill the buffer with data, but TBaseJSONDataSet tries to write to the buffer, without checking if it is nil.

So, I created the patch which solves this.

The patch is attached -- fpjsondataset.diff.
TagsNo tags attached.
Fixed in Revision39841
Attached Files


Zoran Vučenović

2018-09-27 10:39

reporter (2,633 bytes)

Zoran Vučenović

2018-09-27 10:40


fpjsondataset.diff (511 bytes)   
Index: packages/fcl-db/src/json/fpjsondataset.pp
--- packages/fcl-db/src/json/fpjsondataset.pp	(revision 39830)
+++ packages/fcl-db/src/json/fpjsondataset.pp	(working copy)
@@ -967,7 +967,7 @@
   Result:=(F<>Nil) and not (F.JSONType in [jtUnknown,jtNull]);
-  if not Result then
+  if (Buffer=Nil) or not Result then
   case Field.DataType of
fpjsondataset.diff (511 bytes)   

Michael Van Canneyt

2018-09-30 08:18

administrator   ~0111098

Fixed. Thanks for reporting!

I backported lots of changes from the pas2js version of TJSONDataset.
The JSON dataset should now be properly read/write, bookmarks work correctly.

Please note that this includes splitting the extjs dataset to a separate unit

Next steps are having a delta package available, and local indices (sorting).

Zoran Vučenović

2018-10-01 10:31

reporter   ~0111154

Thank you!

Issue History

Date Modified Username Field Change
2018-09-27 10:39 Zoran Vučenović New Issue
2018-09-27 10:39 Zoran Vučenović File Added:
2018-09-27 10:40 Zoran Vučenović File Added: fpjsondataset.diff
2018-09-27 11:12 Michael Van Canneyt Assigned To => Michael Van Canneyt
2018-09-27 11:12 Michael Van Canneyt Status new => assigned
2018-09-30 08:18 Michael Van Canneyt Fixed in Revision => 39841
2018-09-30 08:18 Michael Van Canneyt Note Added: 0111098
2018-09-30 08:18 Michael Van Canneyt Status assigned => resolved
2018-09-30 08:18 Michael Van Canneyt Fixed in Version => 3.3.1
2018-09-30 08:18 Michael Van Canneyt Resolution open => fixed
2018-09-30 08:18 Michael Van Canneyt Target Version => 3.2.0
2018-10-01 10:31 Zoran Vučenović Note Added: 0111154
2018-10-01 10:31 Zoran Vučenović Status resolved => closed