From b31444261e18ca97af8c23532048edc596ac1fc3 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Fri, 18 Mar 2022 18:57:55 -0400 Subject: [COV] cuesheet.c var line could be uninitialized Change-Id: Id753ecc28f4029e05032be0c0ac6ecd27e9e370f --- apps/cuesheet.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'apps') diff --git a/apps/cuesheet.c b/apps/cuesheet.c index 45354ad14d..a9169d4494 100644 --- a/apps/cuesheet.c +++ b/apps/cuesheet.c @@ -222,22 +222,25 @@ bool parse_cuesheet(struct cuesheet_file *cue_file, struct cuesheet *cue) /* Look for a Unicode BOM */ unsigned char bom_read = 0; - read(fd, line, BOM_UTF_8_SIZE); - if(!memcmp(line, BOM_UTF_8, BOM_UTF_8_SIZE)) + if (read(fd, line, BOM_UTF_8_SIZE) > 0) { - char_enc = CHAR_ENC_UTF_8; - bom_read = BOM_UTF_8_SIZE; - } - else if(!memcmp(line, BOM_UTF_16_LE, BOM_UTF_16_SIZE)) - { - char_enc = CHAR_ENC_UTF_16_LE; - bom_read = BOM_UTF_16_SIZE; - } - else if(!memcmp(line, BOM_UTF_16_BE, BOM_UTF_16_SIZE)) - { - char_enc = CHAR_ENC_UTF_16_BE; - bom_read = BOM_UTF_16_SIZE; + if(!memcmp(line, BOM_UTF_8, BOM_UTF_8_SIZE)) + { + char_enc = CHAR_ENC_UTF_8; + bom_read = BOM_UTF_8_SIZE; + } + else if(!memcmp(line, BOM_UTF_16_LE, BOM_UTF_16_SIZE)) + { + char_enc = CHAR_ENC_UTF_16_LE; + bom_read = BOM_UTF_16_SIZE; + } + else if(!memcmp(line, BOM_UTF_16_BE, BOM_UTF_16_SIZE)) + { + char_enc = CHAR_ENC_UTF_16_BE; + bom_read = BOM_UTF_16_SIZE; + } } + if (bom_read < BOM_UTF_8_SIZE) lseek(fd, cue_file->pos + bom_read, SEEK_SET); if (is_embedded) -- cgit v1.2.3