Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
141
Merge Requests
141
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
a0d26594
Commit
a0d26594
authored
Dec 16, 2011
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix possible resource leak with ImageMagick conversion
parent
10e16f2c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
19 deletions
+9
-19
product/PortalTransforms/libtransforms/imagemagick_transform.py
...t/PortalTransforms/libtransforms/imagemagick_transform.py
+9
-19
No files found.
product/PortalTransforms/libtransforms/imagemagick_transform.py
View file @
a0d26594
...
@@ -26,26 +26,16 @@ class ImageMagickTransforms:
...
@@ -26,26 +26,16 @@ class ImageMagickTransforms:
if
depth
:
if
depth
:
parameter_list
.
extend
([
'-depth'
,
'%s'
%
depth
,
'-type'
,
'Palette'
])
parameter_list
.
extend
([
'-depth'
,
'%s'
%
depth
,
'-type'
,
'Palette'
])
parameter_list
.
append
(
'%s:-'
%
self
.
format
)
parameter_list
.
append
(
'%s:-'
%
self
.
format
)
process
=
subprocess
.
Popen
(
parameter_list
,
with
subprocess
.
Popen
(
parameter_list
,
stdin
=
subprocess
.
PIPE
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
close_fds
=
True
)
close_fds
=
True
)
as
p
:
imgin
,
imgout
,
err
=
process
.
stdin
,
process
.
stdout
,
process
.
stderr
# XXX: The only portable way is to pass what stdin.write can accept,
# which is a string for PIPE.
image
,
err
=
p
.
communicate
(
str
(
orig
))
def
writeData
(
stream
,
data
):
data
.
setData
(
image
)
if
isinstance
(
data
,
str
):
stream
.
write
(
data
)
else
:
# Use PData structure to prevent
# consuming too much memory
while
data
is
not
None
:
stream
.
write
(
data
.
data
)
data
=
data
.
next
writeData
(
imgin
,
orig
)
imgin
.
close
()
data
.
setData
(
imgout
.
read
())
return
data
return
data
def
register
():
def
register
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment