Skip to content

Commit 1af25e8

Browse files
committed
Fix reference counting
1 parent 2929df0 commit 1af25e8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Diff for: src/main/java/com/marcospassos/phpserializer/Writer.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public Writer writeSerializableObjectStart(String className)
8181
buffer.append("\":");
8282

8383
subWriter = new Writer();
84+
subWriter.pointer = pointer + 1;
8485

8586
return subWriter;
8687
}
@@ -102,7 +103,9 @@ void writeSerializableObjectEnd() {
102103
buffer.append(data);
103104
buffer.append("}");
104105

105-
pointer += subWriter.getPointer();
106+
pointer = subWriter.getPointer() + 1;
107+
108+
subWriter = null;
106109
}
107110

108111
/**

Diff for: src/test/java/com/marcospassos/phpserializer/WriterTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void writeSerializableObject() throws Exception
4949
writer.writeSerializableObjectEnd();
5050

5151
assertEquals("C:3:\"Foo\":20:{a:1:{i:0;s:3:\"bar\";}}", writer.getResult());
52-
assertEquals(3, writer.getPointer());
52+
assertEquals(4, writer.getPointer());
5353
}
5454

5555
@Test(expected = IllegalStateException.class)

0 commit comments

Comments
 (0)