diff --git a/UnicodeProperties.cpp b/UnicodeProperties.cpp
index 64dd351f..b614e985 100644
--- a/UnicodeProperties.cpp
+++ b/UnicodeProperties.cpp
@@ -118,11 +118,16 @@ bool loadUnicodeTable(UCPropTable *table, const char *filename, bool useChecksum
 
 	FILE *fp = fopen(filename, "r");
 	if (!fp) {
-		log( LOG_WARN, "uni: Couldn't open %s for reading", filename );
+		log(LOG_WARN, "Couldn't open [%s] for reading", filename );
 		return false;
 	}
 	fseek(fp,0,SEEK_END);
-	size_t fileSize = ftell(fp);
+	long fileSize = ftell(fp);
+	if( fileSize < 0 ) {
+		fclose(fp);
+		log(LOG_WARN, "Getting size of [%s] failed", filename);
+		return false;
+	}
 	rewind(fp);
 	char *buf = (char*)mmalloc(fileSize, "Unicode");
 	if (!buf) {
@@ -131,7 +136,7 @@ bool loadUnicodeTable(UCPropTable *table, const char *filename, bool useChecksum
 		return false;
 	}
 	size_t nread = fread(buf, 1, fileSize, fp);
-	if (nread != fileSize) {
+	if (nread != (size_t)fileSize) {
 		fclose(fp);
 		mfree(buf, fileSize, "Unicode");
 		log(LOG_WARN, "uni: error reading %s", filename);