Skip to content

Commit 7c6bf38

Browse files
committed
strlen and fix schema
1 parent 445b415 commit 7c6bf38

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

source/pdal/pdalc_pipeline.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ extern "C"
118118
std::string out = strm.str();
119119
if (out.length() > size - 1) out.resize(size - 1);
120120
std::strncpy(buffer, out.c_str(), size);
121-
return std::min(out.length() + 1, size);
121+
return strlen(out.c_str());
122122
}
123123
catch (const std::exception &e)
124124
{
@@ -146,7 +146,7 @@ extern "C"
146146
std::string out = strm.str();
147147
if (out.length() > size - 1) out.resize(size - 1);
148148
std::strncpy(metadata, out.c_str(), size);
149-
return std::min(out.length() + 1, size);
149+
return strlen(out.c_str());
150150
}
151151
catch (const std::exception &e)
152152
{
@@ -165,14 +165,17 @@ extern "C"
165165

166166
try
167167
{
168+
if (! ptr->m_executed)
169+
throw pdal_error("Pipeline has not been executed!");
170+
168171
std::stringstream strm;
169172
MetadataNode meta = ptr->manager->pointTable().layout()->toMetadata();
170173
MetadataNode root = meta.clone("schema");
171174
pdal::Utils::toJSON(root, strm);
172175
std::string out = strm.str();
173176
if (out.length() > size - 1) out.resize(size - 1);
174177
std::strncpy(schema, out.c_str(), size);
175-
return std::min(out.length() + 1, size);
178+
return strlen(out.c_str());
176179
}
177180
catch (const std::exception &e)
178181
{

tests/pdal/test_pdalc_pipeline.c.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ TEST testPDALGetPipelineAsString(void)
149149
char json10[10];
150150
size = PDALGetPipelineAsString(pipeline, json10, 10);
151151

152-
if (size != 10 )
152+
if (size != 9 )
153153
{
154154
PDALDisposePipeline(pipeline);
155155
pipeline = NULL;
@@ -220,7 +220,7 @@ TEST testPDALGetPipelineMetadata(void)
220220
char json10[10];
221221
size = PDALGetPipelineMetadata(pipeline, json10, 10);
222222

223-
if (size != 10 )
223+
if (size != 9 )
224224
{
225225
PDALDisposePipeline(pipeline);
226226
pipeline = NULL;
@@ -284,7 +284,7 @@ TEST testPDALGetPipelineSchema(void)
284284
char json10[10];
285285
size = PDALGetPipelineSchema(pipeline, json10, 10);
286286

287-
if (size != 10 )
287+
if (size != 9 )
288288
{
289289
PDALDisposePipeline(pipeline);
290290
pipeline = NULL;

0 commit comments

Comments
 (0)