From 38a944a6c88e320a3fdec41a8d38bd63f72b77ea Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 28 Nov 2010 22:25:10 +0100 Subject: Check length of CRYST1 line --- src/cell.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/cell.c') 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 ); -- cgit v1.2.3