From 1d01254ca1f9d14b6575ad081f02d4c963545252 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 31 Oct 2008 00:05:24 +0200 Subject: [PATCH] obexd: Change xfer callback and dc_cb order in the event of a disconnection This is mainly working around a bug in the gwobex API. Since it doesn't have proper refcounting the xfer callback can free the gwobex ctx and so the second callback fails. It could of course happen in the other direction too (dc_cb calls gw_obex_close) but since no known code is using dc_cb it's at least a little safer this way. --- obexd/gwobex/obex-priv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/obexd/gwobex/obex-priv.c b/obexd/gwobex/obex-priv.c index 792cb4ff1..8a4e22e07 100644 --- a/obexd/gwobex/obex-priv.c +++ b/obexd/gwobex/obex-priv.c @@ -637,10 +637,10 @@ gboolean gw_obex_cb(GIOChannel *chan, GIOCondition cond, gpointer data) { debug("gw_obex_cb: error or connection closed\n"); obex_link_error(ctx); GW_OBEX_UNLOCK(ctx); - if (ctx->xfer && ctx->xfer->cb) - ctx->xfer->cb(ctx->xfer, ctx->xfer->cb_data); if (ctx->dc_cb) ctx->dc_cb(ctx, ctx->dc_data); + if (ctx->xfer && ctx->xfer->cb) + ctx->xfer->cb(ctx->xfer, ctx->xfer->cb_data); return FALSE; } -- 2.47.3