summaryrefslogtreecommitdiff
path: root/plugins/AdvaImg/src/Metadata/IPTC.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/AdvaImg/src/Metadata/IPTC.cpp')
-rw-r--r--plugins/AdvaImg/src/Metadata/IPTC.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/plugins/AdvaImg/src/Metadata/IPTC.cpp b/plugins/AdvaImg/src/Metadata/IPTC.cpp
index 817beddf98..bde718c986 100644
--- a/plugins/AdvaImg/src/Metadata/IPTC.cpp
+++ b/plugins/AdvaImg/src/Metadata/IPTC.cpp
@@ -41,15 +41,27 @@ read_iptc_profile(FIBITMAP *dib, const BYTE *dataptr, unsigned int datalen) {
size_t length = datalen;
BYTE *profile = (BYTE*)dataptr;
+ const char *JPEG_AdobeCM_Tag = "Adobe_CM";
+
std::string Keywords;
std::string SupplementalCategory;
WORD tag_id;
- if (!dataptr || (datalen == 0)) {
+ if(!dataptr || (datalen == 0)) {
return FALSE;
}
+ if(datalen > 8) {
+ if(memcmp(JPEG_AdobeCM_Tag, dataptr, 8) == 0) {
+ // the "Adobe_CM" APP13 segment presumably contains color management information,
+ // but the meaning of the data is currently unknown.
+ // If anyone has an idea about what this means, please let me know.
+ return FALSE;
+ }
+ }
+
+
// create a tag
FITAG *tag = FreeImage_CreateTag();
@@ -59,7 +71,7 @@ read_iptc_profile(FIBITMAP *dib, const BYTE *dataptr, unsigned int datalen) {
// find start of the BIM portion of the binary data
size_t offset = 0;
while(offset < length - 1) {
- if ((profile[offset] == 0x1C) && (profile[offset+1] == 0x02))
+ if((profile[offset] == 0x1C) && (profile[offset+1] == 0x02))
break;
offset++;
}
@@ -88,6 +100,11 @@ read_iptc_profile(FIBITMAP *dib, const BYTE *dataptr, unsigned int datalen) {
break;
}
+ if(tagByteCount == 0) {
+ // go to next tag
+ continue;
+ }
+
// process the tag
tag_id = (WORD)(tagType | (directoryType << 8));
@@ -211,7 +228,7 @@ append_iptc_tag(BYTE *profile, unsigned *profile_size, WORD id, DWORD length, co
// calculate the new buffer size
size_t buffer_size = (5 + *profile_size + length) * sizeof(BYTE);
buffer = (BYTE*)malloc(buffer_size);
- if (!buffer)
+ if(!buffer)
return NULL;
// add the header