Commit 1966d036 authored by Lefebvre, Jordan's avatar Lefebvre, Jordan
Browse files

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

parent de668f69
Pipeline #44396 passed with stages
in 15 minutes and 35 seconds
......@@ -127,11 +127,12 @@ bool ARLDataStream::write_record_header(const ARLRecordHeader& rheader)
radix_line(" initial value = " << rheader.var1);
// 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,
rheader.month, rheader.day, rheader.hour, rheader.ic, rheader.il,
std::stoi(rheader.cgrid.c_str()), rheader.kvar.c_str(), rheader.nexp,
rheader.prec, rheader.var1);
recordHeader[50] = '\0'; // null-terminate
p->stream->writeString(std::string(recordHeader),
ARLDataStream::PImpl::recordHeaderLength);
......@@ -221,7 +222,7 @@ bool ARLDataStream::write_index_header(const ARLRecordHeader& rheader,
radix_line(" Size of each record = " << p->recordSize);
const size_t MAX_HEADER_LENGTH = 10000;
char indexHeaderMain[ARLDataStream::PImpl::indexHeaderLength],
char indexHeaderMain[ARLDataStream::PImpl::indexHeaderLength+1],
indexHeaderVars[MAX_HEADER_LENGTH];
int pos = 0;
......@@ -250,6 +251,7 @@ bool ARLDataStream::write_index_header(const ARLRecordHeader& rheader,
iheader.orient, iheader.tang_lat, iheader.sync_xp, iheader.sync_yp,
iheader.sync_lat, iheader.sync_lon, iheader.dummy, iheader.nx,
iheader.ny, iheader.nz, iheader.z_flag, headerLength);
indexHeaderMain[ARLDataStream::PImpl::indexHeaderLength] = '\0'; // null-terminate
// Write the two elements of the header
p->stream->writeString(std::string(indexHeaderMain),
......
Markdown is supported
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