diff --git a/BlendFile/Reader.cs b/BlendFile/Reader.cs
index 677e2eb..7979ec1 100644
--- a/BlendFile/Reader.cs
+++ b/BlendFile/Reader.cs
@@ -139,7 +139,7 @@ public class Reader {
/// Array of s containing attributes
/// offset in bytes from where structure starts in the block
private void FillObject(Kaitai.BlendFile.FileBlock block, ref object? obj, FieldInfo[] fieldMetadata, long startOffset = 0) {
- if(block.Code == "ENDB") return;
+ if(block.Code == "ENDB") return;// ENDB is a special block that does not contain any data
foreach (var field in fieldMetadata) {
//Get the DNAFieldAttribute of the current field
var attrib = field.GetCustomAttribute();
@@ -166,7 +166,7 @@ public class Reader {
//Get the information of the fields of the new object
var fieldInfo = newObj.GetType().GetFields();
- //If the field is a pointer, we need to dereference it
+ //If the field is not a pointer, we need to dereference it
if (!attrib.IsPointer) {
long relAddr = block.MemAddr.ToMemAddr() + offset;
if (objects.TryGetValue((relAddr, newObj.GetType()), out object? o)) {
@@ -177,6 +177,8 @@ public class Reader {
//Fill the object with the data from the block (this is recursive)
FillObject(block, ref newObj, fieldInfo, offset);
} else { // if is a pointer, make a pointer to the pointer
+ long memAddr = data.ToMemAddr();
+ if (memAddr == 0) continue; //nullPointer, no need to store the reference
pointers.TryAdd(block.MemAddr.ToMemAddr() + offset, data.ToMemAddr());
}
}