Menu

#77 Fix for big endian (v1.0.6)

v1.0 (example)
open
nobody
None
5
2021-11-25
2021-11-25
No

As written in the patch:

MolfileReadCountsLine: fix storing n_atoms, n_bonds members after reading short size

In MolfileReadCountsLine() (in INCHI_BASE/src/mol_fmt1.c), currently
ctab->n_atoms and ctab->n_bonds, which have int type (as defined in src/mol_fmt.h),
are passed to be MolfileReadField(), and to be treated there as if they have
short size (as MOL_FMT_SHORT_INT_DATA is also passed to the argument of
MolfileReadField(), and also the comment shows).

This causes a error on big endian system such as s390x, where for example
reading the line:

1 0 0 0 0 0 0 0 0 0999 V2000

On little endian (64bit) system, ctab->n_atoms is correctly stored as 1, but on
s390x (big endian 64bit) system, ctab->n_atoms gets 65536 (= 1<<16), which is
unexpected.

To fix this, once store the read value to short size local variable, then
copy the value to ctab->n_atoms or so later.

1 Attachments

Discussion


Log in to post a comment.

MongoDB Logo MongoDB