don't crash when dict is empty file

This commit is contained in:
Eric House 2011-11-13 17:06:57 -08:00
parent 4edca4ee4c
commit d6fecaa3d3

View file

@ -1,6 +1,6 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make MEMDEBUG=TRUE"; -*- */ /* -*- compile-command: "make MEMDEBUG=TRUE -j3"; -*- */
/* /*
* Copyright 1997-2009 by Eric House (xwords@eehouse.org). All rights * Copyright 1997 - 2011 by Eric House (xwords@eehouse.org). All rights
* reserved. * reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -219,7 +219,7 @@ initFromDictFile( LinuxDictionaryCtxt* dctx, const char* fileName )
const XP_U8* ptr; const XP_U8* ptr;
struct stat statbuf; struct stat statbuf;
if ( 0 != stat( fileName, &statbuf ) ) { if ( 0 != stat( fileName, &statbuf ) || 0 == statbuf.st_size ) {
goto closeAndExit; goto closeAndExit;
} }
dctx->dictLength = statbuf.st_size; dctx->dictLength = statbuf.st_size;