Skip to content

Commit 0ff0ab5

Browse files
committed
cppcheck fixes
1 parent 144e7d1 commit 0ff0ab5

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

frmts/msg/xritheaderparser.cpp

+14-10
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,20 @@ XRITHeaderParser::XRITHeaderParser(std::ifstream &ifile)
4242
{
4343
unsigned char *buf =
4444
(unsigned char *)std::malloc(totalHeaderLength);
45-
std::memcpy(
46-
buf, probeBuf,
47-
probeSize); // save what we have already read when probing
48-
ifile.read((char *)buf + probeSize,
49-
totalHeaderLength -
50-
probeSize); // read the rest of the header section
51-
parseHeader(buf, totalHeaderLength);
52-
std::free(buf);
53-
54-
m_isValid = true;
45+
if (buf)
46+
{
47+
std::memcpy(
48+
buf, probeBuf,
49+
probeSize); // save what we have already read when probing
50+
ifile.read(
51+
(char *)buf + probeSize,
52+
totalHeaderLength -
53+
probeSize); // read the rest of the header section
54+
parseHeader(buf, totalHeaderLength);
55+
std::free(buf);
56+
57+
m_isValid = true;
58+
}
5559
}
5660
}
5761

scripts/cppcheck.sh

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ for dirname in alg port gcore ogr frmts gnm apps fuzzers; do
111111
-DPCIDSK_FRMT_UINT64="\"%llu\"" \
112112
-DGNMGFIDFormat="\"%lld\"" \
113113
-DGDAL_RELEASE_NAME="\"dummy\"" \
114+
-DGDAL_RELEASE_NICKNAME="\"dummy\"" \
114115
"-DBANDMAP_TYPE=int*" \
115116
-DSQLITE_UTF8=1 \
116117
-DSQLITE_DETERMINISTIC=0x000000800 \

0 commit comments

Comments
 (0)