@@ -66,9 +66,11 @@ mutable struct CosDocImpl <: CosDoc
66
66
io = util_open (fp," r" )
67
67
sz = filesize (fp)
68
68
ps = io
69
- new (fp, sz, io, ps, 0 , " " , 0 , (0 , 0 ),
70
- Dict {CosIndirectObjectRef, CosObjectLoc} (),
71
- [], [], [], CosNull, false , false , nothing , 0 )
69
+ this = new (fp, sz, io, ps, 0 , " " , 0 , (0 , 0 ),
70
+ Dict {CosIndirectObjectRef, CosObjectLoc} (),
71
+ [], [], [], CosNull, false , false , nothing , 0 )
72
+ finalizer (x-> util_close (x. ps), this)
73
+ return this
72
74
end
73
75
end
74
76
@@ -113,7 +115,6 @@ called if you have opened the document by 'cosDocOpen'. Documents opened with
113
115
`pdDocOpen` do not need to use this method.
114
116
"""
115
117
function cosDocClose (doc:: CosDocImpl )
116
- util_close (doc. ps)
117
118
for path in doc. tmpfiles
118
119
rm (path)
119
120
end
@@ -132,6 +133,7 @@ function cosDocOpen(fp::AbstractString; access::Function=identity)
132
133
doc = CosDocImpl (abspath (fp))
133
134
ps = doc. ps
134
135
h = read_header (ps)
136
+ h[1 ] == 0 && error (E_BAD_HEADER)
135
137
doc. version = (h[1 ], h[2 ])
136
138
doc. header = String (h[3 ])
137
139
doc. hoffset = h[4 ]
0 commit comments