diff options
author | John Crispin <john@phrozen.org> | 2018-01-03 11:56:48 +0100 |
---|---|---|
committer | John Crispin <john@phrozen.org> | 2018-01-17 09:59:58 +0100 |
commit | 212ceb1b021bc0db19201894e1e9633fa6a25638 (patch) | |
tree | fdcb36f6c23472718b572ddd8d2b1e43501fadc2 | |
parent | d57907c2b30170bdab7d59a4fad6e514f1861bbb (diff) | |
download | ubus-212ceb1b021bc0db19201894e1e9633fa6a25638.tar.gz |
valgrind complained about these
==18834== Warning: invalid file descriptor -1 in syscall close()
==18834== at 0x5326D20: __close_nocancel (syscall-template.S:84)
==18834== by 0x5046DC7: ubus_process_obj_msg (libubus-obj.c:143)
==18834== by 0x5045E98: ubus_process_msg (libubus.c:106)
==18834== by 0x50468D0: ubus_handle_data (libubus-io.c:314)
==18834== by 0x4E3D125: uloop_run_events (uloop.c:198)
==18834== by 0x4E3D125: uloop_run_timeout (uloop.c:555)
==18834== by 0x109BEF: uloop_run (uloop.h:111)
==18834== by 0x109BEF: main (main.c:25)
Signed-off-by: John Crispin <john@phrozen.org>
-rw-r--r-- | libubus-obj.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libubus-obj.c b/libubus-obj.c index b301965..c1931b3 100644 --- a/libubus-obj.c +++ b/libubus-obj.c @@ -31,7 +31,8 @@ ubus_process_unsubscribe(struct ubus_context *ctx, struct ubus_msghdr *hdr, if (s->remove_cb) s->remove_cb(ctx, s, blob_get_u32(attrbuf[UBUS_ATTR_TARGET])); - close(fd); + if (fd >= 0) + close(fd); } static void @@ -45,7 +46,8 @@ ubus_process_notify(struct ubus_context *ctx, struct ubus_msghdr *hdr, if (obj->subscribe_cb) obj->subscribe_cb(ctx, obj); - close(fd); + if (fd >= 0) + close(fd); } static void ubus_process_invoke(struct ubus_context *ctx, struct ubus_msghdr *hdr, |