Permalink
Browse files

Don't attempt to send data not available for sending yet. Analysed

and fixed by Remco <remco at d-compu.dyndns.org>, thanks!
  • Loading branch information...
1 parent 4b2ee79 commit a102b72ae89097c98f6e3e93f6ded8ea669b696f Alexandre Ratchov committed Oct 22, 2011
Showing with 9 additions and 7 deletions.
  1. +9 −7 lib/libsndio/aucat.c
View
@@ -1,4 +1,4 @@
-/* $OpenBSD: aucat.c,v 1.51 2011/10/17 21:09:11 ratchov Exp $ */
+/* $OpenBSD: aucat.c,v 1.52 2011/10/22 10:23:44 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -157,16 +157,18 @@ size_t
aucat_wdata(struct aucat *hdl, const void *buf, size_t len, unsigned wbpf, int *eof)
{
ssize_t n;
+ size_t datasize;
switch (hdl->wstate) {
case WSTATE_IDLE:
- if (len > AMSG_DATAMAX)
- len = AMSG_DATAMAX;
- len -= len % wbpf;
- if (len == 0)
- len = wbpf;
+ datasize = len;
+ if (datasize > AMSG_DATAMAX)
+ datasize = AMSG_DATAMAX;
+ datasize -= datasize % wbpf;
+ if (datasize == 0)
+ datasize = wbpf;
hdl->wmsg.cmd = htonl(AMSG_DATA);
- hdl->wmsg.u.data.size = htonl(len);
+ hdl->wmsg.u.data.size = htonl(datasize);
hdl->wtodo = sizeof(struct amsg);
hdl->wstate = WSTATE_MSG;
/* FALLTHROUGH */

0 comments on commit a102b72

Please sign in to comment.