w2v-server: handle out of dictionary words in a more robust way
diff --git a/w2v-server.pl b/w2v-server.pl
index a956b22..c22aa4c 100755
--- a/w2v-server.pl
+++ b/w2v-server.pl
@@ -527,7 +527,8 @@
 		if (b == -1) {
 			fprintf(stderr, "Out of dictionary word!\n");
 			cn--;
-			break;
+			free(wl);
+			return NULL;
 		}
 	}
   wl->length=cn;
@@ -625,7 +626,7 @@
     cutoff=words;
 
   wl = getTargetWords(st1, search_backw);
-  if(wl->length < 1)
+  if(wl == NULL || wl->length < 1)
     goto end;
 
 	old_words = cutoff;