Skip to content

script: Implement device finish

Uli Schlachter requested to merge psychon/cairo:script-bug-277 into master

Before this commit, calling cairo_device_finish() on a cairo-script context did not actually do anything in the backend. Thus, it was possible to continue emitting output on the script context even after it was finished, which means that API user had no way of preventing use-after-free bugs in their write callback. Bug 277 triggers this via detaching a snapshot, but I guess one could also simply continue drawing to a script surface.

This commit implements the finish function by closing the underlying stream.

However, that was not enough to fix things. This commit also turns writing into a stream into a no-op after the stream was closed.

I checked that the new test case actually fails before this commit and is indeed fixed by it.

Fixes: #277 (closed) Signed-off-by: Uli Schlachter psychon@znc.in

Merge request reports