aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Holberton <taylorcholberton@gmail.com>2017-04-10 12:42:06 -0700
committerTaylor Holberton <taylorcholberton@gmail.com>2017-04-10 12:42:06 -0700
commit001b25ef86c1b3843a6c05d41968eb77b2abf905 (patch)
tree88c0ee29057643867e824d0dfc92a2991eec5930
parent04b47b083101a6855557cde6d638e1e3f26095bb (diff)
adding bounds check only when needed
-rw-r--r--src/pcm.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/pcm.c b/src/pcm.c
index 24f4f2b..ef38c9c 100644
--- a/src/pcm.c
+++ b/src/pcm.c
@@ -677,8 +677,11 @@ int pcm_writei(struct pcm *pcm, const void *data, unsigned int frame_count)
if (pcm->flags & PCM_IN)
return -EINVAL;
- else if ((frame_count > TINYALSA_FRAMES_MAX)
- || (frame_count > INT_MAX))
+#if UINT_MAX > TINYALSA_FRAMES_MAX
+ if (frame_count > TINYALSA_FRAMES_MAX)
+ return -EINVAL;
+#endif
+ if (frame_count > INT_MAX)
return -EINVAL;
x.buf = (void*)data;
@@ -730,8 +733,11 @@ int pcm_readi(struct pcm *pcm, void *data, unsigned int frame_count)
if (!(pcm->flags & PCM_IN))
return -EINVAL;
- else if ((frame_count > TINYALSA_FRAMES_MAX)
- || (frame_count > INT_MAX))
+#if UINT_MAX > TINYALSA_FRAMES_MAX
+ if (frame_count > TINYALSA_FRAMES_MAX)
+ return -EINVAL;
+#endif
+ if (frame_count > INT_MAX)
return -EINVAL;
x.buf = data;