Browse Source

Improve some range checks.

Georgi Chorbadzhiyski 9 years ago
parent
commit
bcab8b796b
2 changed files with 2 additions and 2 deletions
  1. 1
    1
      cmd.c
  2. 1
    1
      videohubctrl.c

+ 1
- 1
cmd.c View File

@@ -275,7 +275,7 @@ bool parse_command(struct videohub_data *data, char *cmd) {
275 275
 		case CMD_VIDEO_OUTPUT_ROUTING:
276 276
 			if (valid_slot) {
277 277
 				unsigned int dest_pos = strtoul(slot_data, NULL, 10);
278
-				if (dest_pos < ARRAY_SIZE(data->outputs))
278
+				if (dest_pos < ARRAY_SIZE(data->inputs))
279 279
 					data->outputs[slot_pos].routed_to = dest_pos;
280 280
 			}
281 281
 			break;

+ 1
- 1
videohubctrl.c View File

@@ -138,7 +138,7 @@ static void print_device_settings(struct videohub_data *d) {
138 138
 	printf_line(70);
139 139
 	printf("|  # | x | %-27s | %-27s |\n", "Input name", "Output name");
140 140
 	printf_line(70);
141
-	for(i = 0; i < d->device.num_video_inputs; i++) {
141
+	for(i = 0; i < MIN(d->device.num_video_outputs, ARRAY_SIZE(d->outputs)); i++) {
142 142
 		printf("| %2d | %c | %-27s | %-27s |\n",
143 143
 			i + 1,
144 144
 			d->outputs[i].locked ? (d->outputs[i].locked_other ? 'L' : 'O') : ' ',

Loading…
Cancel
Save