summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorz3bra <contactatz3bradotorg>2016-11-22 08:13:54 +0100
committerz3bra <contactatz3bradotorg>2016-11-22 08:13:54 +0100
commit9009ccdb0dc325e9db12ffffec7b752dce48469c (patch)
tree0173f24f707a69cd312d9355d283b63b2faec710
parentb53745979a6a8a944ddc31f3187e8fa0f40448a0 (diff)
Use ternary to prevent passing negative size to fiforead()
-rw-r--r--ratox.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ratox.c b/ratox.c
index c0ebf2a..d5ca466 100644
--- a/ratox.c
+++ b/ratox.c
@@ -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;