tUse ternary to prevent passing negative size to fiforead() - ratox - FIFO based tox client
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 9009ccdb0dc325e9db12ffffec7b752dce48469c
(DIR) parent b53745979a6a8a944ddc31f3187e8fa0f40448a0
(HTM) Author: z3bra <contactatz3bradotorg>
Date: Tue, 22 Nov 2016 08:13:54 +0100
Use ternary to prevent passing negative size to fiforead()
Diffstat:
M ratox.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/ratox.c b/ratox.c
t@@ -488,12 +488,12 @@ sendfriendcalldata(struct friend *f)
TOXAV_ERR_SEND_FRAME err;
n = fiforead(f->dirfd, &f->fd[FCALL_IN], ffiles[FCALL_IN],
- f->av.frame + (f->av.state & INCOMPLETE)/INCOMPLETE * f->av.n,
- framesize * sizeof(int16_t) - (f->av.state & INCOMPLETE)/INCOMPLETE * f->av.n);
+ f->av.frame + (f->av.state & INCOMPLETE ? f->av.n : 0),
+ framesize * sizeof(int16_t) - (f->av.state & INCOMPLETE ? f->av.n : 0));
if (n == 0) {
f->av.state &= ~OUTGOING;
return;
- } else if (n < 0 || n > framesize * sizeof(int16_t)) {
+ } else if (n < 0) {
return;
} else if (n == (framesize * sizeof(int16_t) - (f->av.state & INCOMPLETE) * f->av.n)) {
f->av.state &= ~INCOMPLETE;