Skip to content

Commit

Permalink
Check parameter to avoid uninitialized var
Browse files Browse the repository at this point in the history
reported by coverity
  • Loading branch information
zsx committed Sep 14, 2014
1 parent 75fd147 commit 8336a45
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/s-unicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,9 @@ ConversionResult ConvertUTF8toUTF32 (
if (utf == 8) bp += 3, len -= 3;
else if (utf == -16 || utf == 16) bp += 2, len -= 2;
else if (utf == -32 || utf == 32) bp += 4, len -= 4;
else return NULL;
} else {
return NULL;

This comment has been minimized.

Copy link
@earl

earl Nov 17, 2014

This else branch along with the return NULL is (most likely unintended) change of behaviour for Decode_UTF_String.

A call to What_UTF can legitimately return 0 to indicate that no BOM is present. So without this change, when utf == -1 is passed into Decode_UTF_String, the function decodes according to the BOM if present, or falls back to UTF-8 otherwise. With this change, when utf == -1 the function no longer decodes strings without a BOM.

}
}

Expand Down

0 comments on commit 8336a45

Please sign in to comment.