Commit 2f147bba authored by LEFEBVREJP email's avatar LEFEBVREJP email
Browse files

Merge branch 'arldatastream-bug' into 'master'

Adding null-terminator to end of character array in arldatastream.

See merge request !70
parents de668f69 1966d036
Pipeline #44544 passed with stages
in 16 minutes and 46 seconds
...@@ -127,11 +127,12 @@ bool ARLDataStream::write_record_header(const ARLRecordHeader& rheader) ...@@ -127,11 +127,12 @@ bool ARLDataStream::write_record_header(const ARLRecordHeader& rheader)
radix_line(" initial value = " << rheader.var1); radix_line(" initial value = " << rheader.var1);
// Construct index header string // Construct index header string
char recordHeader[50]; char recordHeader[51];
sprintf(recordHeader, "%2d%2d%2d%2d%2d%2d%2d%4s%4d%14.7E%14.7E", year, sprintf(recordHeader, "%2d%2d%2d%2d%2d%2d%2d%4s%4d%14.7E%14.7E", year,
rheader.month, rheader.day, rheader.hour, rheader.ic, rheader.il, rheader.month, rheader.day, rheader.hour, rheader.ic, rheader.il,
std::stoi(rheader.cgrid.c_str()), rheader.kvar.c_str(), rheader.nexp, std::stoi(rheader.cgrid.c_str()), rheader.kvar.c_str(), rheader.nexp,
rheader.prec, rheader.var1); rheader.prec, rheader.var1);
recordHeader[50] = '\0'; // null-terminate
p->stream->writeString(std::string(recordHeader), p->stream->writeString(std::string(recordHeader),
ARLDataStream::PImpl::recordHeaderLength); ARLDataStream::PImpl::recordHeaderLength);
...@@ -221,7 +222,7 @@ bool ARLDataStream::write_index_header(const ARLRecordHeader& rheader, ...@@ -221,7 +222,7 @@ bool ARLDataStream::write_index_header(const ARLRecordHeader& rheader,
radix_line(" Size of each record = " << p->recordSize); radix_line(" Size of each record = " << p->recordSize);
const size_t MAX_HEADER_LENGTH = 10000; const size_t MAX_HEADER_LENGTH = 10000;
char indexHeaderMain[ARLDataStream::PImpl::indexHeaderLength], char indexHeaderMain[ARLDataStream::PImpl::indexHeaderLength+1],
indexHeaderVars[MAX_HEADER_LENGTH]; indexHeaderVars[MAX_HEADER_LENGTH];
int pos = 0; int pos = 0;
...@@ -250,6 +251,7 @@ bool ARLDataStream::write_index_header(const ARLRecordHeader& rheader, ...@@ -250,6 +251,7 @@ bool ARLDataStream::write_index_header(const ARLRecordHeader& rheader,
iheader.orient, iheader.tang_lat, iheader.sync_xp, iheader.sync_yp, iheader.orient, iheader.tang_lat, iheader.sync_xp, iheader.sync_yp,
iheader.sync_lat, iheader.sync_lon, iheader.dummy, iheader.nx, iheader.sync_lat, iheader.sync_lon, iheader.dummy, iheader.nx,
iheader.ny, iheader.nz, iheader.z_flag, headerLength); iheader.ny, iheader.nz, iheader.z_flag, headerLength);
indexHeaderMain[ARLDataStream::PImpl::indexHeaderLength] = '\0'; // null-terminate
// Write the two elements of the header // Write the two elements of the header
p->stream->writeString(std::string(indexHeaderMain), p->stream->writeString(std::string(indexHeaderMain),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment