diff --git a/src/syncterm/ooii.c b/src/syncterm/ooii.c
index e3c8199ea810f9b68c9da73292bea91f54723ef4..76c6f45bbfb673126aae23a6fe13a8ea6400994c 100644
--- a/src/syncterm/ooii.c
+++ b/src/syncterm/ooii.c
@@ -303,7 +303,7 @@ static void getBlock(unsigned char **codeStr, char *menuBlock)
 	menuBlock[0]=0;
 	if(**codeStr=='_')
 		(*codeStr)++;
-	while(**codeStr != '_' && **codeStr != '|') {
+	while(**codeStr && **codeStr != '_' && **codeStr != '|') {
 		*(menuBlock++) = *((*codeStr)++);
 		*menuBlock=0;
 	}
@@ -345,7 +345,7 @@ static int readSmallMenu(unsigned char *codeStr) {
 	int  yy;
 	int  zz;
 	unsigned char *origCodeStr=codeStr;
-	char buf[256];
+	char buf[260];
 
 	switch ((char)codeStr[0]) {
 		case 'a':