OLD | NEW |
1 /* | 1 /* |
2 * jdmarker.c | 2 * jdmarker.c |
3 * | 3 * |
4 * Copyright (C) 1991-1998, Thomas G. Lane. | 4 * Copyright (C) 1991-1998, Thomas G. Lane. |
5 * Copyright (C) 2012, D. R. Commander. | 5 * Copyright (C) 2012, D. R. Commander. |
6 * This file is part of the Independent JPEG Group's software. | 6 * This file is part of the Independent JPEG Group's software. |
7 * For conditions of distribution and use, see the accompanying README file. | 7 * For conditions of distribution and use, see the accompanying README file. |
8 * | 8 * |
9 * This file contains routines to decode JPEG datastream markers. | 9 * This file contains routines to decode JPEG datastream markers. |
10 * Most of the complexity arises from our desire to support input | 10 * Most of the complexity arises from our desire to support input |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 | 316 |
317 TRACEMS1(cinfo, 1, JTRC_SOS, n); | 317 TRACEMS1(cinfo, 1, JTRC_SOS, n); |
318 | 318 |
319 if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN) | 319 if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN) |
320 ERREXIT(cinfo, JERR_BAD_LENGTH); | 320 ERREXIT(cinfo, JERR_BAD_LENGTH); |
321 | 321 |
322 cinfo->comps_in_scan = n; | 322 cinfo->comps_in_scan = n; |
323 | 323 |
324 /* Collect the component-spec parameters */ | 324 /* Collect the component-spec parameters */ |
325 | 325 |
326 for (i = 0; i < cinfo->num_components; i++) | 326 for (i = 0; i < MAX_COMPS_IN_SCAN; i++) |
327 cinfo->cur_comp_info[i] = NULL; | 327 cinfo->cur_comp_info[i] = NULL; |
328 | 328 |
329 for (i = 0; i < n; i++) { | 329 for (i = 0; i < n; i++) { |
330 INPUT_BYTE(cinfo, cc, return FALSE); | 330 INPUT_BYTE(cinfo, cc, return FALSE); |
331 INPUT_BYTE(cinfo, c, return FALSE); | 331 INPUT_BYTE(cinfo, c, return FALSE); |
332 | 332 |
333 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 333 for (ci = 0, compptr = cinfo->comp_info; |
| 334 » ci < cinfo->num_components && ci < MAX_COMPS_IN_SCAN; |
334 ci++, compptr++) { | 335 ci++, compptr++) { |
335 if (cc == compptr->component_id && !cinfo->cur_comp_info[ci]) | 336 if (cc == compptr->component_id && !cinfo->cur_comp_info[ci]) |
336 goto id_found; | 337 goto id_found; |
337 } | 338 } |
338 | 339 |
339 ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc); | 340 ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc); |
340 | 341 |
341 id_found: | 342 id_found: |
342 | 343 |
343 cinfo->cur_comp_info[i] = compptr; | 344 cinfo->cur_comp_info[i] = compptr; |
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 { | 1494 { |
1494 my_marker_ptr marker = (my_marker_ptr) cinfo->marker; | 1495 my_marker_ptr marker = (my_marker_ptr) cinfo->marker; |
1495 | 1496 |
1496 if (marker_code == (int) M_COM) | 1497 if (marker_code == (int) M_COM) |
1497 marker->process_COM = routine; | 1498 marker->process_COM = routine; |
1498 else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) | 1499 else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) |
1499 marker->process_APPn[marker_code - (int) M_APP0] = routine; | 1500 marker->process_APPn[marker_code - (int) M_APP0] = routine; |
1500 else | 1501 else |
1501 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); | 1502 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); |
1502 } | 1503 } |
OLD | NEW |