summaryrefslogtreecommitdiff
path: root/modules/cairo-surface.cpp
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2019-04-20 15:26:34 -0700
committerPhilip Chimento <philip.chimento@gmail.com>2019-04-21 20:34:59 -0700
commit0038bf9ada40f439f018e7e4e04e5c68cd2aca16 (patch)
tree1309185f940d86f89ee96c63c3ff34720fdd6ea6 /modules/cairo-surface.cpp
parent17021714193d79b1c8031ea4f02a8243b0ec14fc (diff)
downloadgjs-0038bf9ada40f439f018e7e4e04e5c68cd2aca16.tar.gz
cairo: Don't free unowned Cairo structs
It seems that in all other release functions, we don't free the GIArgument's data in the transfer-none case. That would end up freeing a passed-in argument that was owned by the caller, or a return value that was owned by the callee. This bug was spotted by compiling with -Wunused-parameter.
Diffstat (limited to 'modules/cairo-surface.cpp')
-rw-r--r--modules/cairo-surface.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/modules/cairo-surface.cpp b/modules/cairo-surface.cpp
index b726db50..529ef059 100644
--- a/modules/cairo-surface.cpp
+++ b/modules/cairo-surface.cpp
@@ -302,7 +302,8 @@ surface_release_argument(JSContext *context,
GITransfer transfer,
GArgument *arg)
{
- cairo_surface_destroy((cairo_surface_t*)arg->v_pointer);
+ if (transfer != GI_TRANSFER_NOTHING)
+ cairo_surface_destroy(static_cast<cairo_surface_t*>(arg->v_pointer));
return true;
}