OLD | NEW |
1 /* vim: set ts=8 sw=8 noexpandtab: */ | 1 /* vim: set ts=8 sw=8 noexpandtab: */ |
2 // qcms | 2 // qcms |
3 // Copyright (C) 2009 Mozilla Foundation | 3 // Copyright (C) 2009 Mozilla Foundation |
4 // Copyright (C) 1998-2007 Marti Maria | 4 // Copyright (C) 1998-2007 Marti Maria |
5 // | 5 // |
6 // Permission is hereby granted, free of charge, to any person obtaining | 6 // Permission is hereby granted, free of charge, to any person obtaining |
7 // a copy of this software and associated documentation files (the "Software"), | 7 // a copy of this software and associated documentation files (the "Software"), |
8 // to deal in the Software without restriction, including without limitation | 8 // to deal in the Software without restriction, including without limitation |
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, | 9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, |
10 // and/or sell copies of the Software, and to permit persons to whom the Softwar
e | 10 // and/or sell copies of the Software, and to permit persons to whom the Softwar
e |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 return curve; | 486 return curve; |
487 } | 487 } |
488 | 488 |
489 #define MAX_CLUT_SIZE 500000 // arbitrary | 489 #define MAX_CLUT_SIZE 500000 // arbitrary |
490 #define MAX_CHANNELS 10 // arbitrary | 490 #define MAX_CHANNELS 10 // arbitrary |
491 static void read_nested_curveType(struct mem_source *src, struct curveType *(*cu
rveArray)[MAX_CHANNELS], uint8_t num_channels, uint32_t curve_offset) | 491 static void read_nested_curveType(struct mem_source *src, struct curveType *(*cu
rveArray)[MAX_CHANNELS], uint8_t num_channels, uint32_t curve_offset) |
492 { | 492 { |
493 uint32_t channel_offset = 0; | 493 uint32_t channel_offset = 0; |
494 int i; | 494 int i; |
495 for (i = 0; i < num_channels; i++) { | 495 for (i = 0; i < num_channels; i++) { |
496 » » uint32_t tag_len; | 496 » » uint32_t tag_len = ~0; |
497 | 497 |
498 (*curveArray)[i] = read_curveType(src, curve_offset + channel_of
fset, &tag_len); | 498 (*curveArray)[i] = read_curveType(src, curve_offset + channel_of
fset, &tag_len); |
499 if (!(*curveArray)[i]) { | 499 if (!(*curveArray)[i]) { |
500 invalid_source(src, "invalid nested curveType curve"); | 500 invalid_source(src, "invalid nested curveType curve"); |
501 } | 501 } |
502 | 502 |
| 503 if (tag_len == ~0) { |
| 504 invalid_source(src, "invalid nested curveType tag length
"); |
| 505 return; |
| 506 } |
| 507 |
503 channel_offset += tag_len; | 508 channel_offset += tag_len; |
504 // 4 byte aligned | 509 // 4 byte aligned |
505 if ((tag_len % 4) != 0) | 510 if ((tag_len % 4) != 0) |
506 channel_offset += 4 - (tag_len % 4); | 511 channel_offset += 4 - (tag_len % 4); |
507 } | 512 } |
508 | |
509 } | 513 } |
510 | 514 |
511 static void mAB_release(struct lutmABType *lut) | 515 static void mAB_release(struct lutmABType *lut) |
512 { | 516 { |
513 uint8_t i; | 517 uint8_t i; |
514 | 518 |
515 for (i = 0; i < lut->num_in_channels; i++){ | 519 for (i = 0; i < lut->num_in_channels; i++){ |
516 free(lut->a_curves[i]); | 520 free(lut->a_curves[i]); |
517 } | 521 } |
518 for (i = 0; i < lut->num_out_channels; i++){ | 522 for (i = 0; i < lut->num_out_channels; i++){ |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 { | 1211 { |
1208 qcms_profile *profile = NULL; | 1212 qcms_profile *profile = NULL; |
1209 FILE *file = _wfopen(path, L"rb"); | 1213 FILE *file = _wfopen(path, L"rb"); |
1210 if (file) { | 1214 if (file) { |
1211 profile = qcms_profile_from_file(file); | 1215 profile = qcms_profile_from_file(file); |
1212 fclose(file); | 1216 fclose(file); |
1213 } | 1217 } |
1214 return profile; | 1218 return profile; |
1215 } | 1219 } |
1216 #endif | 1220 #endif |
OLD | NEW |