V638. A terminal null is present inside a string. The '\0xNN' characters were encountered. Probably meant: '\xNN'.


The analyzer has detected a potential error: there is a terminal null character inside a string.

This error usually occurs through a misprint. For example, the "\0x0A" sequence is considered by the program as a sequence of four bytes: { '\0', 'x', '0', 'A' }.

If you want to define the character code in the hexadecimal form, the 'x' character should stand right after the '\' character. If you write "\0", the program will consider it as zero (in the octal format). See also:

Consider an example of incorrect code:

const char *s = "string\0x0D\0x0A";

If you try to print this string, the control characters intended to translate the string will not be used. The output functions will stop at the line-end character '\0'. To fix this bug you should replace "\0x0D\0x0A" with "\x0D\x0A".

This is the fixed code:

const char *s = "string\x0D\x0A";

According to Common Weakness Enumeration, potential errors found by using this diagnostic are classified as CWE-665.

You can look at examples of errors detected by the V638 diagnostic.


Bugs Found

Checked Projects
361
Collected Errors
13 417