aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2010-11-28 22:25:10 +0100
committerThomas White <taw@physics.org>2012-02-22 15:27:07 +0100
commit38a944a6c88e320a3fdec41a8d38bd63f72b77ea (patch)
treefb0ee07d50f1993087279b8de1df46a608e04d62
parent153f4d848a5d75a183e18f8280b28b1ef636ca3d (diff)
Check length of CRYST1 line
-rw-r--r--src/cell.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/cell.c b/src/cell.c
index e95a0573..67c49610 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -821,6 +821,7 @@ static void cell_set_pointgroup_from_pdb(UnitCell *cell, const char *sym)
{
char *new = NULL;
+ if ( strcmp(sym, "P 1") == 0 ) new = "1";
if ( strcmp(sym, "P 63") == 0 ) new = "6";
if ( strcmp(sym, "P 21 21 21") == 0 ) new = "222";
if ( strcmp(sym, "P 2 2 2") == 0 ) new = "222";
@@ -872,11 +873,15 @@ UnitCell *load_cell_from_pdb(const char *filename)
deg2rad(be),
deg2rad(ga));
- sym = strndup(line+55, 10);
- notrail(sym);
- cell_set_pointgroup_from_pdb(cell, sym);
- free(sym);
-
+ if ( strlen(line) > 65 ) {
+ sym = strndup(line+55, 10);
+ notrail(sym);
+ cell_set_pointgroup_from_pdb(cell, sym);
+ free(sym);
+ } else {
+ cell_set_pointgroup_from_pdb(cell, "P 1");
+ ERROR("CRYST1 line without space group.\n");
+ }
}
} while ( rval != NULL );