https://github.com/espeak-ng/espeak-ng/pull/478
---
 src/libespeak-ng/klatt.c   |    2 +-
 src/libespeak-ng/wavegen.c |    6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

--- a/src/libespeak-ng/wavegen.c
+++ b/src/libespeak-ng/wavegen.c
@@ -883,7 +883,7 @@ int Wavegen()
 		if (echo_head >= N_ECHO_BUF)
 			echo_head = 0;
 
-		if (out_ptr >= out_end)
+		if (out_ptr + 2 > out_end)
 			return 1;
 	}
 }
@@ -916,7 +916,7 @@ static int PlaySilence(int length, int r
 		if (echo_head >= N_ECHO_BUF)
 			echo_head = 0;
 
-		if (out_ptr >= out_end)
+		if (out_ptr + 2 > out_end)
 			return 1;
 	}
 	return 0;
@@ -969,7 +969,7 @@ static int PlayWave(int length, int resu
 		if (echo_head >= N_ECHO_BUF)
 			echo_head = 0;
 
-		if (out_ptr >= out_end)
+		if (out_ptr + 2 > out_end)
 			return 1;
 	}
 	return 0;
--- a/src/libespeak-ng/klatt.c
+++ b/src/libespeak-ng/klatt.c
@@ -422,7 +422,7 @@ static int parwave(klatt_frame_ptr frame
 			echo_head = 0;
 
 		sample_count++;
-		if (out_ptr >= out_end)
+		if (out_ptr + 2 > out_end)
 			return 1;
 	}
 	return 0;
