From a53db3ad0a428d550a56f97cba465cf800654c81 Mon Sep 17 00:00:00 2001 From: Alberto Fernandez Date: Thu, 29 Feb 2024 23:25:19 +0100 Subject: [PATCH] DBFReader: row.getString() does not return null for NULL MEMO field Fix #121 --- src/main/java/com/linuxense/javadbf/DBFMemoFile.java | 3 +++ src/main/java/com/linuxense/javadbf/DBFReader.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/linuxense/javadbf/DBFMemoFile.java b/src/main/java/com/linuxense/javadbf/DBFMemoFile.java index 8fcdd3f..8b1b26c 100644 --- a/src/main/java/com/linuxense/javadbf/DBFMemoFile.java +++ b/src/main/java/com/linuxense/javadbf/DBFMemoFile.java @@ -143,6 +143,9 @@ protected byte[] readBinary(int block) { } protected Object readData(int block, DBFDataType type) { + if (block <= 0) { + return null; + } long blockStart = this.blockSize * (long) block; DBFDataType usedType = null; try { diff --git a/src/main/java/com/linuxense/javadbf/DBFReader.java b/src/main/java/com/linuxense/javadbf/DBFReader.java index 3271c52..29ff327 100644 --- a/src/main/java/com/linuxense/javadbf/DBFReader.java +++ b/src/main/java/com/linuxense/javadbf/DBFReader.java @@ -556,7 +556,7 @@ private Object readMemoField(DBFField field) throws IOException { else { nBlock = DBFUtils.readLittleEndianInt(this.dataInputStream); } - if (this.memoFile != null && nBlock != null) { + if (this.memoFile != null && nBlock != null && nBlock.intValue() > 0) { DBFDataType type = field.getType(); if (type == DBFDataType.MEMO && fieldsAsBinary.contains(field.getName().toUpperCase())) { type = DBFDataType.BINARY;