aboutsummaryrefslogtreecommitdiff
path: root/slirp/slirp.c
diff options
context:
space:
mode:
Diffstat (limited to 'slirp/slirp.c')
-rw-r--r--slirp/slirp.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 51de41fc02..322edf51eb 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -1091,6 +1091,17 @@ ssize_t slirp_send(struct socket *so, const void *buf, size_t len, int flags)
return len;
}
+ if (so->s == -1) {
+ /*
+ * This should in theory not happen but it is hard to be
+ * sure because some code paths will end up with so->s == -1
+ * on a failure but don't dispose of the struct socket.
+ * Check specifically, so we don't pass -1 to send().
+ */
+ errno = EBADF;
+ return -1;
+ }
+
return send(so->s, buf, len, flags);
}
@@ -1466,9 +1477,6 @@ static int slirp_state_load(QEMUFile *f, void *opaque, int version_id)
int ret;
struct socket *so = socreate(slirp);
- if (!so)
- return -ENOMEM;
-
ret = vmstate_load_state(f, &vmstate_slirp_socket, so, version_id);
if (ret < 0)