View Issue Details

IDProjectCategoryView StatusLast Update
0034348FPCFCLpublic2018-10-01 12:31
ReporterZoran VučenovićAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.2.0Product Build39830 
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
FPCOldBugId
FPCTarget
Attached Files
  • JSONDataSetBug.zip (2,633 bytes)
  • 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 @@
         R:=FEditRow;
       F:=FFieldMapper.GetJSONDataForField(Field,R);
       Result:=(F<>Nil) and not (F.JSONType in [jtUnknown,jtNull]);
    -  if not Result then
    +  if (Buffer=Nil) or not Result then
         exit;
       case Field.DataType of
         ftfixedwidechar,
    
    fpjsondataset.diff (511 bytes)

Activities

Zoran Vučenović

2018-09-27 12:39

reporter  

JSONDataSetBug.zip (2,633 bytes)

Zoran Vučenović

2018-09-27 12:40

reporter  

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 @@
     R:=FEditRow;
   F:=FFieldMapper.GetJSONDataForField(Field,R);
   Result:=(F<>Nil) and not (F.JSONType in [jtUnknown,jtNull]);
-  if not Result then
+  if (Buffer=Nil) or not Result then
     exit;
   case Field.DataType of
     ftfixedwidechar,
fpjsondataset.diff (511 bytes)

Michael Van Canneyt

2018-09-30 10: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
extjsdataset.pp

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

Zoran Vučenović

2018-10-01 12:31

reporter   ~0111154

Thank you!

Issue History

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