Fixed possible SEGFAULT for inappropriate data.