Skip to content

Commit 73be598

Browse files
authored
Merge pull request #12791 from rouault/gdalmdiminfo_null_string_attribute
gdalmdiminfo: fix crash on a null string attribute
2 parents f7a765d + eb94da4 commit 73be598

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

apps/gdalmdiminfo_lib.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ static void DumpAttrValue(const std::shared_ptr<GDALAttribute> &attr,
395395
serializer.Add(pszStr);
396396
}
397397
}
398+
else
399+
{
400+
serializer.AddNull();
401+
}
398402
}
399403
else
400404
{

autotest/utilities/test_gdalmdiminfo_lib.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,22 @@ def test_gdalmdiminfo_lib_uint64():
288288

289289
ret = gdal.MultiDimInfo(ds, detailed=True)
290290
assert ret["arrays"]["ar"]["values"] == [10000000000]
291+
292+
293+
###############################################################################
294+
295+
296+
def test_gdalmdiminfo_lib_null_string():
297+
298+
drv = gdal.GetDriverByName("MEM")
299+
ds = drv.CreateMultiDimensional("")
300+
rg = ds.GetRootGroup()
301+
rg.CreateAttribute("null_string", [], gdal.ExtendedDataType.CreateString())
302+
303+
ret = gdal.MultiDimInfo(ds)
304+
assert ret == {
305+
"type": "group",
306+
"driver": "MEM",
307+
"name": "/",
308+
"attributes": {"null_string": None},
309+
}

0 commit comments

Comments
 (0)