From b29bb82ddbf82b9989fa1f1e552491a2f6e5504a Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Tue, 23 Aug 2011 13:06:30 +0200 Subject: [PATCH] Fix uninitialized variables when Source_file::get_counts returns early due to !contains (pos_str0) --- lily/source-file.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lily/source-file.cc b/lily/source-file.cc index b42fb7a5b3..041c046d2b 100644 --- a/lily/source-file.cc +++ b/lily/source-file.cc @@ -261,7 +261,11 @@ Source_file::get_counts (char const *pos_str0, int *column, int *byte_offset) const { + // Initialize arguments to defaults, needed if pos_str0 is not in source *line_number = 0; + *line_char = 0; + *column = 0; + *byte_offset = 0; if (!contains (pos_str0)) return; @@ -276,10 +280,6 @@ Source_file::get_counts (char const *pos_str0, string line_begin (line_start, left); char const *line_chars = line_begin.c_str (); - *line_char = 0; - *column = 0; - *byte_offset = 0; - while (left > 0) { size_t thislen = utf8_char_len (*line_chars); -- 2.39.2