Skip to content

Commit 9f3d922

Browse files
committed
better OV/OL handling
- we had the size set incorrectly - improved byteswap rules - version bump - better frame data print
1 parent b611994 commit 9f3d922

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## master
22

3+
## 1.0.3, 7/10/23
4+
5+
- improve handling of OV and OL [jcupitt]
6+
- better frame data print [jcupitt]
7+
38
## 1.0.2, 5/10/23
49

510
- fix a crash and some error pileups [bgilbert]

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project(
88
],
99
license : 'MIT',
1010
meson_version : '>=0.50',
11-
version : '1.0.2'
11+
version : '1.0.3'
1212
)
1313
if not meson.is_subproject()
1414
meson.add_dist_script(

src/dicom-dict.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ static const struct _DcmVRTable vr_table[] = {
101101

102102
{DCM_VR_UC, "UC", DCM_VR_CLASS_STRING_MULTI, 0, DCM_CAPACITY_UC, 4},
103103

104-
{DCM_VR_OL, "OL", DCM_VR_CLASS_BINARY, 0, 0, 4},
105-
{DCM_VR_OV, "OV", DCM_VR_CLASS_BINARY, 0, 0, 4},
104+
{DCM_VR_OL, "OL", DCM_VR_CLASS_BINARY, 4, 0, 4},
105+
{DCM_VR_OV, "OV", DCM_VR_CLASS_BINARY, 8, 0, 4},
106106

107107
{DCM_VR_SV, "SV", DCM_VR_CLASS_NUMERIC_INTEGER, 8, 0, 4},
108108
{DCM_VR_UV, "UV", DCM_VR_CLASS_NUMERIC_INTEGER, 8, 0, 4},

src/dicom-file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ static bool print_pixeldata_create(DcmError **error,
14461446

14471447
uint32_t n = MIN(16, length);
14481448
for (uint32_t i = 0; i < n; i++) {
1449-
printf("%02x", value[i]);
1449+
printf("%02x", value[i] & 0xff);
14501450

14511451
if (i % size == size - 1) {
14521452
printf(" ");

src/dicom-parse.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static bool is_big_endian(void)
155155
static void byteswap(char *data, size_t length, size_t size)
156156
{
157157
// only swap if the data is "swappable"
158-
if (length >= size && length % size == 0) {
158+
if (size > 0 && length >= size && length % size == 0) {
159159
size_t n_elements = length / size;
160160

161161
switch (size) {
@@ -600,15 +600,15 @@ static bool parse_element_body(DcmParseState *state,
600600

601601
// read to a static char buffer, if possible
602602
if ((int64_t) length + 1 >= INPUT_BUFFER_SIZE) {
603-
value = value_free = DCM_MALLOC(state->error, (size_t) length + 1);
603+
value = value_free = DCM_MALLOC(state->error,
604+
(size_t) length + 1);
604605
if (value == NULL) {
605606
return false;
606607
}
607608
} else {
608609
value = input_buffer;
609610
}
610611

611-
612612
if (!dcm_require(state, value, length, position)) {
613613
if (value_free != NULL) {
614614
free(value_free);
@@ -625,11 +625,8 @@ static bool parse_element_body(DcmParseState *state,
625625
}
626626
}
627627

628-
if (vr_class == DCM_VR_CLASS_NUMERIC_DECIMAL ||
629-
vr_class == DCM_VR_CLASS_NUMERIC_INTEGER) {
630-
if (state->big_endian) {
631-
byteswap(value, length, size);
632-
}
628+
if (size > 0 && state->big_endian) {
629+
byteswap(value, length, size);
633630
}
634631

635632
if (state->parse->element_create &&

0 commit comments

Comments
 (0)