Fixed memory corruption in passes/abc/blifparse.cc
authorClifford Wolf <clifford@clifford.at>
Tue, 11 Mar 2014 12:09:01 +0000 (13:09 +0100)
committerClifford Wolf <clifford@clifford.at>
Tue, 11 Mar 2014 12:09:01 +0000 (13:09 +0100)
passes/abc/blifparse.cc

index 2d46d1a8ef6525f22fa8ddfa4081353b12fe03c4..1d4da19ad1b383ca59455c6331a55566222d25a2 100644 (file)
@@ -40,7 +40,7 @@ static bool read_next_line(char *&buffer, size_t &buffer_size, int &line_count,
                }
 
                if (buffer_len == 0 || buffer[buffer_len-1] == '\\') {
-                       if (buffer[buffer_len-1] == '\\')
+                       if (buffer_len > 0 && buffer[buffer_len-1] == '\\')
                                buffer[--buffer_len] = 0;
                        line_count++;
                        if (fgets(buffer+buffer_len, buffer_size-buffer_len, f) == NULL)