From 06f4532cf6b434e0027ae892620e23e944ed20f5 Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Mon, 23 Aug 2010 07:39:26 -0500 Subject: [PATCH] regedit: Don't call ungetc() twice consecutively. Spotted by Sylvain Hitier. --- programs/regedit/regproc.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c index 82349f62cae..edf3d004102 100644 --- a/programs/regedit/regproc.c +++ b/programs/regedit/regproc.c @@ -680,19 +680,18 @@ static void processRegLinesA(FILE *in, char* first_chars) } if(s[i] == '\r'){ /* read the next character iff it's \n */ + if(i+2 >= size_to_get){ + /* buffer too short, so put back the EOL char to + * read next cycle */ + ungetc('\r', in); + break; + } s[i+1] = fgetc(in); if(s[i+1] != '\n'){ ungetc(s[i+1], in); i = i+1; - }else{ - if(i+2 >= size_to_get){ - /* buffer too short, so put back the EOL chars to - * read next cycle */ - ungetc('\n', in); - ungetc('\r', in); - }else - i = i+2; - } + }else + i = i+2; break; } if(s[i] == '\n'){