mirror of
https://github.com/pgpointcloud/pointcloud.git
synced 2025-12-08 20:36:04 +00:00
Fix crash on cloning schema with missing dimension name/description
Closes #66 Includes testcase
This commit is contained in:
parent
53b4fa1dcb
commit
3011d8dace
@ -147,8 +147,10 @@ static void
|
||||
test_schema_clone(void)
|
||||
{
|
||||
int i;
|
||||
PCSCHEMA *myschema;
|
||||
PCSCHEMA *clone = pc_schema_clone(schema);
|
||||
hashtable *hash, *chash;
|
||||
char *xmlstr;
|
||||
CU_ASSERT_EQUAL(clone->pcid, schema->pcid);
|
||||
CU_ASSERT_EQUAL(clone->ndims, schema->ndims);
|
||||
CU_ASSERT_EQUAL(clone->size, schema->size);
|
||||
@ -185,6 +187,17 @@ test_schema_clone(void)
|
||||
}
|
||||
|
||||
pc_schema_free(clone);
|
||||
|
||||
/* See https://github.com/pgpointcloud/pointcloud/issues/66 */
|
||||
xmlstr = "<pc:PointCloudSchema xmlns:pc='x'><pc:dimension><pc:position>1</pc:position></pc:dimension></pc:PointCloudSchema>";
|
||||
i = pc_schema_from_xml(xmlstr, &myschema);
|
||||
CU_ASSERT_EQUAL(i, PC_SUCCESS);
|
||||
clone = pc_schema_clone(myschema);
|
||||
CU_ASSERT_EQUAL(clone->ndims, myschema->ndims);
|
||||
CU_ASSERT_EQUAL(clone->dims[0]->name, NULL);
|
||||
CU_ASSERT_EQUAL(clone->dims[0]->description, NULL);
|
||||
pc_schema_free(myschema);
|
||||
pc_schema_free(clone);
|
||||
}
|
||||
|
||||
/* REGISTER ***********************************************************/
|
||||
|
||||
@ -164,8 +164,8 @@ pc_dimension_clone(const PCDIMENSION *dim)
|
||||
/* Copy all the inline data */
|
||||
memcpy(pcd, dim, sizeof(PCDIMENSION));
|
||||
/* Copy the referenced data */
|
||||
pcd->name = pcstrdup(dim->name);
|
||||
pcd->description = pcstrdup(dim->description);
|
||||
if ( dim->name ) pcd->name = pcstrdup(dim->name);
|
||||
if ( dim->description ) pcd->description = pcstrdup(dim->description);
|
||||
return pcd;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user