From 4b8d258cff85678c7ac90c03e337f9316e1f7b98 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 14 Dec 2014 15:09:55 +0100 Subject: lib/nfs/Connection: fix crash while canceling a failing Open() The method NfsConnection::CancellableCallback::Callback() will always invoke NfsConnection::Close() on the file handle, even if the void pointer is not a nfsfh. This can happen if the Open() was not successful, e.g. when the file does not exist. --- src/lib/nfs/Connection.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/nfs/Connection.cxx b/src/lib/nfs/Connection.cxx index 410711275..c57cb9b79 100644 --- a/src/lib/nfs/Connection.cxx +++ b/src/lib/nfs/Connection.cxx @@ -156,8 +156,10 @@ NfsConnection::CancellableCallback::Callback(int err, void *data) allocated file handle immediately */ assert(close_fh == nullptr); - struct nfsfh *fh = (struct nfsfh *)data; - connection.Close(fh); + if (err >= 0) { + struct nfsfh *fh = (struct nfsfh *)data; + connection.Close(fh); + } } else if (close_fh != nullptr) connection.DeferClose(close_fh); -- cgit v1.2.3