Skip to content

Commit de9e99a

Browse files
authored
Merge pull request ArtifexSoftware#33 from Filipowicz251/master
Update GhostscriptPipedOutput.cs
2 parents 303418a + 74e49d1 commit de9e99a

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

Ghostscript.NET/GhostscriptPipedOutput.cs

+11-10
Original file line numberDiff line numberDiff line change
@@ -154,18 +154,19 @@ public string ClientHandle
154154
public void ReadGhostscriptPipeOutput(object state)
155155
{
156156
// create BinaryReader instance through which we will read out Ghostscript output
157-
BinaryReader reader = new BinaryReader(_pipe);
158-
159-
// allocate memory space for the incoming output data
160-
byte[] buffer = new byte[_pipe.InBufferSize];
157+
using(BinaryReader reader = new BinaryReader(_pipe))
158+
{
159+
// allocate memory space for the incoming output data
160+
byte[] buffer = new byte[_pipe.InBufferSize];
161161

162-
int readCount = 0;
162+
int readCount = 0;
163163

164-
// read untill we have something to read
165-
while ((readCount = reader.Read(buffer, 0, buffer.Length)) > 0)
166-
{
167-
// write the output to our local memory stream
168-
_data.Write(buffer, 0, readCount);
164+
// read untill we have something to read
165+
while ((readCount = reader.Read(buffer, 0, buffer.Length)) > 0)
166+
{
167+
// write the output to our local memory stream
168+
_data.Write(buffer, 0, readCount);
169+
}
169170
}
170171
}
171172

0 commit comments

Comments
 (0)