Skip to content

Commit 3664f5b

Browse files
Merge pull request #2665 from kevinbackhouse/metadata-null-checks
Check if the metadata is NULL
2 parents a89c02f + 1119a68 commit 3664f5b

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

src/nikonmn_int.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3384,7 +3384,7 @@ std::ostream& Nikon3MakerNote::printExternalFlashData2(std::ostream& os, const V
33843384

33853385
std::ostream& Nikon3MakerNote::printFlashMasterDataFl6(std::ostream& os, const Value& value, const ExifData* metadata) {
33863386
std::ios::fmtflags f(os.flags());
3387-
if (value.count() != 1 || value.typeId() != unsignedByte) {
3387+
if (value.count() != 1 || value.typeId() != unsignedByte || !metadata) {
33883388
os << "(" << value << ")";
33893389
os.flags(f);
33903390
return os;
@@ -3413,7 +3413,7 @@ std::ostream& Nikon3MakerNote::printFlashMasterDataFl6(std::ostream& os, const V
34133413

34143414
std::ostream& Nikon3MakerNote::printFlashMasterDataFl7(std::ostream& os, const Value& value, const ExifData* metadata) {
34153415
std::ios::fmtflags f(os.flags());
3416-
if (value.count() != 1 || value.typeId() != unsignedByte) {
3416+
if (value.count() != 1 || value.typeId() != unsignedByte || !metadata) {
34173417
os << "(" << value << ")";
34183418
os.flags(f);
34193419
return os;
@@ -3480,7 +3480,7 @@ std::ostream& Nikon3MakerNote::printFlashGroupBCControlData(std::ostream& os, co
34803480

34813481
std::ostream& Nikon3MakerNote::printFlashGroupADataFl6(std::ostream& os, const Value& value, const ExifData* metadata) {
34823482
std::ios::fmtflags f(os.flags());
3483-
if (value.count() != 1 || value.typeId() != unsignedByte) {
3483+
if (value.count() != 1 || value.typeId() != unsignedByte || !metadata) {
34843484
os << "(" << value << ")";
34853485
os.flags(f);
34863486
return os;
@@ -3509,7 +3509,7 @@ std::ostream& Nikon3MakerNote::printFlashGroupADataFl6(std::ostream& os, const V
35093509

35103510
std::ostream& Nikon3MakerNote::printFlashGroupADataFl7(std::ostream& os, const Value& value, const ExifData* metadata) {
35113511
std::ios::fmtflags f(os.flags());
3512-
if (value.count() != 1 || value.typeId() != unsignedByte) {
3512+
if (value.count() != 1 || value.typeId() != unsignedByte || !metadata) {
35133513
os << "(" << value << ")";
35143514
os.flags(f);
35153515
return os;
@@ -3538,7 +3538,7 @@ std::ostream& Nikon3MakerNote::printFlashGroupADataFl7(std::ostream& os, const V
35383538

35393539
std::ostream& Nikon3MakerNote::printFlashGroupBDataFl6(std::ostream& os, const Value& value, const ExifData* metadata) {
35403540
std::ios::fmtflags f(os.flags());
3541-
if (value.count() != 1 || value.typeId() != unsignedByte) {
3541+
if (value.count() != 1 || value.typeId() != unsignedByte || !metadata) {
35423542
os << "(" << value << ")";
35433543
os.flags(f);
35443544
return os;
@@ -3567,7 +3567,7 @@ std::ostream& Nikon3MakerNote::printFlashGroupBDataFl6(std::ostream& os, const V
35673567

35683568
std::ostream& Nikon3MakerNote::printFlashGroupBDataFl7(std::ostream& os, const Value& value, const ExifData* metadata) {
35693569
std::ios::fmtflags f(os.flags());
3570-
if (value.count() != 1 || value.typeId() != unsignedByte) {
3570+
if (value.count() != 1 || value.typeId() != unsignedByte || !metadata) {
35713571
os << "(" << value << ")";
35723572
os.flags(f);
35733573
return os;
@@ -3596,7 +3596,7 @@ std::ostream& Nikon3MakerNote::printFlashGroupBDataFl7(std::ostream& os, const V
35963596

35973597
std::ostream& Nikon3MakerNote::printFlashGroupCDataFl6(std::ostream& os, const Value& value, const ExifData* metadata) {
35983598
std::ios::fmtflags f(os.flags());
3599-
if (value.count() != 1 || value.typeId() != unsignedByte) {
3599+
if (value.count() != 1 || value.typeId() != unsignedByte || !metadata) {
36003600
os << "(" << value << ")";
36013601
os.flags(f);
36023602
return os;
@@ -3625,7 +3625,7 @@ std::ostream& Nikon3MakerNote::printFlashGroupCDataFl6(std::ostream& os, const V
36253625

36263626
std::ostream& Nikon3MakerNote::printFlashGroupCDataFl7(std::ostream& os, const Value& value, const ExifData* metadata) {
36273627
std::ios::fmtflags f(os.flags());
3628-
if (value.count() != 1 || value.typeId() != unsignedByte) {
3628+
if (value.count() != 1 || value.typeId() != unsignedByte || !metadata) {
36293629
os << "(" << value << ")";
36303630
os.flags(f);
36313631
return os;

src/sonymn_int.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ std::ostream& SonyMakerNote::printWBShiftABGM(std::ostream& os, const Value& val
827827
}
828828

829829
std::ostream& SonyMakerNote::printFocusMode2(std::ostream& os, const Value& value, const ExifData* metadata) {
830-
if (value.count() != 1 || value.typeId() != unsignedByte) {
830+
if (value.count() != 1 || value.typeId() != unsignedByte || !metadata) {
831831
os << "(" << value << ")";
832832
return os;
833833
}
@@ -854,7 +854,7 @@ std::ostream& SonyMakerNote::printFocusMode2(std::ostream& os, const Value& valu
854854
}
855855

856856
std::ostream& SonyMakerNote::printAFAreaModeSetting(std::ostream& os, const Value& value, const ExifData* metadata) {
857-
if (value.count() != 1 || value.typeId() != unsignedByte) {
857+
if (value.count() != 1 || value.typeId() != unsignedByte || !metadata) {
858858
os << "(" << value << ")";
859859
return os;
860860
}
@@ -891,7 +891,7 @@ std::ostream& SonyMakerNote::printAFAreaModeSetting(std::ostream& os, const Valu
891891
}
892892

893893
std::ostream& SonyMakerNote::printFlexibleSpotPosition(std::ostream& os, const Value& value, const ExifData* metadata) {
894-
if (value.count() != 2 || value.typeId() != unsignedShort) {
894+
if (value.count() != 2 || value.typeId() != unsignedShort || !metadata) {
895895
os << "(" << value << ")";
896896
return os;
897897
}
@@ -916,7 +916,7 @@ std::ostream& SonyMakerNote::printFlexibleSpotPosition(std::ostream& os, const V
916916
}
917917

918918
std::ostream& SonyMakerNote::printAFPointSelected(std::ostream& os, const Value& value, const ExifData* metadata) {
919-
if (value.count() != 1 || value.typeId() != unsignedByte) {
919+
if (value.count() != 1 || value.typeId() != unsignedByte || !metadata) {
920920
os << "(" << value << ")";
921921
return os;
922922
}
@@ -967,7 +967,7 @@ std::ostream& SonyMakerNote::printAFPointSelected(std::ostream& os, const Value&
967967
}
968968

969969
std::ostream& SonyMakerNote::printAFPointsUsed(std::ostream& os, const Value& value, const ExifData* metadata) {
970-
if (value.typeId() != unsignedByte) {
970+
if (value.typeId() != unsignedByte || !metadata) {
971971
os << "(" << value << ")";
972972
return os;
973973
}
@@ -994,7 +994,7 @@ std::ostream& SonyMakerNote::printAFPointsUsed(std::ostream& os, const Value& va
994994
}
995995

996996
std::ostream& SonyMakerNote::printAFTracking(std::ostream& os, const Value& value, const ExifData* metadata) {
997-
if (value.count() != 1 || value.typeId() != unsignedByte) {
997+
if (value.count() != 1 || value.typeId() != unsignedByte || !metadata) {
998998
os << "(" << value << ")";
999999
return os;
10001000
}
@@ -1297,7 +1297,7 @@ std::ostream& SonyMakerNote::printImageSize(std::ostream& os, const Value& value
12971297
}
12981298

12991299
std::ostream& SonyMakerNote::printFocusMode(std::ostream& os, const Value& value, const ExifData* metadata) {
1300-
if (value.count() != 1 || value.typeId() != unsignedShort) {
1300+
if (value.count() != 1 || value.typeId() != unsignedShort || !metadata) {
13011301
os << "(" << value << ")";
13021302
return os;
13031303
}
@@ -1314,7 +1314,7 @@ std::ostream& SonyMakerNote::printFocusMode(std::ostream& os, const Value& value
13141314
}
13151315

13161316
std::ostream& SonyMakerNote::printAFMode(std::ostream& os, const Value& value, const ExifData* metadata) {
1317-
if (value.count() != 1 || value.typeId() != unsignedShort) {
1317+
if (value.count() != 1 || value.typeId() != unsignedShort || !metadata) {
13181318
os << "(" << value << ")";
13191319
return os;
13201320
}
@@ -1336,7 +1336,7 @@ std::ostream& SonyMakerNote::printAFMode(std::ostream& os, const Value& value, c
13361336
}
13371337

13381338
std::ostream& SonyMakerNote::printFocusMode3(std::ostream& os, const Value& value, const ExifData* metadata) {
1339-
if (value.count() != 1 || value.typeId() != unsignedShort) {
1339+
if (value.count() != 1 || value.typeId() != unsignedShort || !metadata) {
13401340
os << "(" << value << ")";
13411341
return os;
13421342
}
@@ -1353,7 +1353,7 @@ std::ostream& SonyMakerNote::printFocusMode3(std::ostream& os, const Value& valu
13531353

13541354
std::ostream& SonyMakerNote::printHighISONoiseReduction2(std::ostream& os, const Value& value,
13551355
const ExifData* metadata) {
1356-
if (value.count() != 1 || value.typeId() != unsignedShort) {
1356+
if (value.count() != 1 || value.typeId() != unsignedShort || !metadata) {
13571357
os << "(" << value << ")";
13581358
return os;
13591359
}
@@ -1799,7 +1799,7 @@ const TagInfo* SonyMakerNote::tagListFp() {
17991799

18001800
std::ostream& SonyMakerNote::printSony2FpAmbientTemperature(std::ostream& os, const Value& value,
18011801
const ExifData* metadata) {
1802-
if (value.count() != 1)
1802+
if (value.count() != 1 || !metadata)
18031803
return os << "(" << value << ")";
18041804

18051805
auto pos = metadata->findKey(ExifKey("Exif.Sony2Fp.0x0002"));
@@ -1840,7 +1840,7 @@ std::ostream& SonyMakerNote::printSony2FpFocusMode(std::ostream& os, const Value
18401840

18411841
std::ostream& SonyMakerNote::printSony2FpFocusPosition2(std::ostream& os, const Value& value,
18421842
const ExifData* metadata) {
1843-
if (value.count() != 1)
1843+
if (value.count() != 1 || !metadata)
18441844
os << "(" << value << ")";
18451845
else {
18461846
std::string model;
@@ -1879,7 +1879,7 @@ const TagInfo* SonyMakerNote::tagListSonyMisc1() {
18791879

18801880
std::ostream& SonyMakerNote::printSonyMisc1CameraTemperature(std::ostream& os, const Value& value,
18811881
const ExifData* metadata) {
1882-
if (value.count() != 1)
1882+
if (value.count() != 1 || !metadata)
18831883
return os << "(" << value << ")";
18841884

18851885
auto pos = metadata->findKey(ExifKey("Exif.SonyMisc1.0x0004"));
@@ -1944,7 +1944,7 @@ const TagInfo* SonyMakerNote::tagListSonyMisc2b() {
19441944

19451945
std::ostream& SonyMakerNote::printSonyMisc2bLensZoomPosition(std::ostream& os, const Value& value,
19461946
const ExifData* metadata) {
1947-
if (value.count() != 1)
1947+
if (value.count() != 1 || !metadata)
19481948
return os << "(" << value << ")";
19491949

19501950
std::string model;
@@ -1966,7 +1966,7 @@ std::ostream& SonyMakerNote::printSonyMisc2bLensZoomPosition(std::ostream& os, c
19661966

19671967
std::ostream& SonyMakerNote::printSonyMisc2bFocusPosition2(std::ostream& os, const Value& value,
19681968
const ExifData* metadata) {
1969-
if (value.count() != 1)
1969+
if (value.count() != 1 || !metadata)
19701970
return os << "(" << value << ")";
19711971

19721972
std::string model;
@@ -2052,7 +2052,7 @@ const TagInfo* SonyMakerNote::tagListSonyMisc3c() {
20522052

20532053
std::ostream& SonyMakerNote::printSonyMisc3cShotNumberSincePowerUp(std::ostream& os, const Value& value,
20542054
const ExifData* metadata) {
2055-
if (value.count() != 1 || value.typeId() != unsignedLong)
2055+
if (value.count() != 1 || value.typeId() != unsignedLong || !metadata)
20562056
return os << "(" << value << ")";
20572057

20582058
std::string model;
@@ -2083,7 +2083,7 @@ std::ostream& SonyMakerNote::printSonyMisc3cSequenceNumber(std::ostream& os, con
20832083
}
20842084

20852085
std::ostream& SonyMakerNote::printSonyMisc3cQuality2(std::ostream& os, const Value& value, const ExifData* metadata) {
2086-
if (value.count() != 1 || value.typeId() != unsignedByte)
2086+
if (value.count() != 1 || value.typeId() != unsignedByte || !metadata)
20872087
return os << "(" << value << ")";
20882088

20892089
std::string model;
@@ -2108,7 +2108,7 @@ std::ostream& SonyMakerNote::printSonyMisc3cQuality2(std::ostream& os, const Val
21082108

21092109
std::ostream& SonyMakerNote::printSonyMisc3cSonyImageHeight(std::ostream& os, const Value& value,
21102110
const ExifData* metadata) {
2111-
if (value.count() != 1 || value.typeId() != unsignedShort)
2111+
if (value.count() != 1 || value.typeId() != unsignedShort || !metadata)
21122112
return os << "(" << value << ")";
21132113

21142114
std::string model;
@@ -2131,7 +2131,7 @@ std::ostream& SonyMakerNote::printSonyMisc3cSonyImageHeight(std::ostream& os, co
21312131

21322132
std::ostream& SonyMakerNote::printSonyMisc3cModelReleaseYear(std::ostream& os, const Value& value,
21332133
const ExifData* metadata) {
2134-
if (value.count() != 1 || value.typeId() != unsignedByte)
2134+
if (value.count() != 1 || value.typeId() != unsignedByte || !metadata)
21352135
return os << "(" << value << ")";
21362136

21372137
std::string model;

0 commit comments

Comments
 (0)