Skip to contentSkip to conversation

sound/oss/gus_wave.c: fix off by one errors

PATCH New Adrian Bunk 1 participant 1 message Mar 25, 2005 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sound/oss/gus_wave.c: fix off by one errors

This patch fixes two off by one errors found by the Coverity checker. In both cases, the variables are later used as indexes for arrays with MAX_PATCH elements.

sound/oss/gus_wave.c renamed from sound/oss/gus_wave.c.old +2 -2
@@ -1085,7 +1085,7 @@
 {
 	int sample_no;
 
-	if (instr_no < 0 || instr_no > MAX_PATCH)
+	if (instr_no < 0 || instr_no >= MAX_PATCH)
 		instr_no = 0;	/* Default to acoustic piano */
 
 	if (voice < 0 || voice > 31)
@@ -1676,7 +1676,7 @@
 
 	instr = patch.instr_no;
 
-	if (instr < 0 || instr > MAX_PATCH)
+	if (instr < 0 || instr >= MAX_PATCH)
 	{
 /*		printk(KERN_ERR "GUS: Invalid patch number %d\n", instr);*/
 		return -EINVAL;