Commit 2a92a4d19bd3f6ed386514812a1a69b738675a9d

antirez 2014-03-13T12:27:53

Check read() return value in getCursorPosition().

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/linenoise.c b/linenoise.c
index 2460127..26c21ab 100644
--- a/linenoise.c
+++ b/linenoise.c
@@ -257,7 +257,7 @@ static int getCursorPosition(int ifd, int ofd) {
 
     /* Read the response: ESC [ rows ; cols R */
     while (i < sizeof(buf)-1) {
-        read(ifd,buf+i,1);
+        if (read(ifd,buf+i,1) != 1) break;
         if (buf[i] == 'R') break;
         i++;
     }