emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem report #109: base/src/emacs/src/coding.c (decode_coding_utf_16);


From: Dan Nicolaescu
Subject: Problem report #109: base/src/emacs/src/coding.c (decode_coding_utf_16); UNINIT
Date: Tue, 2 Dec 2008 14:17:09 -0800 (PST)

CID: 109
Checker: UNINIT (help)
File: base/src/emacs/src/coding.c
Function: decode_coding_utf_16
Description: Using uninitialized value "consumed_chars_base"


Event var_decl: Declared variable "consumed_chars_base" without initializer
Also see events: [uninit_use]

1640      int consumed_chars = 0, consumed_chars_base;
1641      int multibytep = coding->src_multibyte;
1642      enum utf_bom_type bom = CODING_UTF_16_BOM (coding);
1643      enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding);
1644      int surrogate = CODING_UTF_16_SURROGATE (coding);
1645      Lisp_Object attr, charset_list;

At conditional (1): "((0), (((0), ((Vcoding_system_hash_table & 
-8)->key_and_value & -8))->contents[((2 * (coding)->id) + 1)] & 
-8))->contents[2] == Qdos" taking true path

1646      int eol_crlf = EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
1647      int byte_after_cr1 = -1, byte_after_cr2 = -1;
1648    

At conditional (2): "0" taking false path

1649      CODING_GET_INFO (coding, attr, charset_list);
1650    

At conditional (3): "bom == 2" taking true path

1651      if (bom == utf_with_bom)
1652        {
1653          int c, c1, c2;
1654    
1655          src_base = src;

At conditional (4): "src == src_end" taking true path
At conditional (5): "src_base < src" taking true path

1656          ONE_MORE_BYTE (c1);
1657          ONE_MORE_BYTE (c2);
1658          c = (c1 << 8) | c2;
1659    
1660          if (endian == utf_16_big_endian
1661              ? c != 0xFEFF : c != 0xFFFE)
1662            {
1663              /* The first two bytes are not BOM.  Treat them as bytes
1664                 for a normal character.  */
1665              src = src_base;
1666              coding->errors++;
1667            }
1668          CODING_UTF_16_BOM (coding) = utf_without_bom;
1669        }
1670      else if (bom == utf_detect_bom)
1671        {
1672          /* We have already tried to detect BOM and failed in
1673             detect_coding.  */
1674          CODING_UTF_16_BOM (coding) = utf_without_bom;
1675        }
1676    
1677      while (1)
1678        {
1679          int c, c1, c2;
1680    
1681          src_base = src;
1682          consumed_chars_base = consumed_chars;
1683    
1684          if (charbuf + 2 >= charbuf_end)
1685            break;
1686    
1687          if (byte_after_cr1 >= 0)
1688            c1 = byte_after_cr1, byte_after_cr1 = -1;
1689          else
1690            ONE_MORE_BYTE (c1);
1691          if (c1 < 0)
1692            {
1693              *charbuf++ = -c1;
1694              continue;
1695            }
1696          if (byte_after_cr2 >= 0)
1697            c2 = byte_after_cr2, byte_after_cr2 = -1;
1698          else
1699            ONE_MORE_BYTE (c2);
1700          if (c2 < 0)
1701            {
1702              *charbuf++ = ASCII_BYTE_P (c1) ? c1 : BYTE8_TO_CHAR (c1);
1703              *charbuf++ = -c2;
1704              continue;
1705            }
1706          c = (endian == utf_16_big_endian
1707               ? ((c1 << 8) | c2) : ((c2 << 8) | c1));
1708    
1709          if (surrogate)
1710            {
1711              if (! UTF_16_LOW_SURROGATE_P (c))
1712                {
1713                  if (endian == utf_16_big_endian)
1714                    c1 = surrogate >> 8, c2 = surrogate & 0xFF;
1715                  else
1716                    c1 = surrogate & 0xFF, c2 = surrogate >> 8;
1717                  *charbuf++ = c1;
1718                  *charbuf++ = c2;
1719                  coding->errors++;
1720                  if (UTF_16_HIGH_SURROGATE_P (c))
1721                    CODING_UTF_16_SURROGATE (coding) = surrogate = c;
1722                  else
1723                    *charbuf++ = c;
1724                }
1725              else
1726                {
1727                  c = ((surrogate - 0xD800) << 10) | (c - 0xDC00);
1728                  CODING_UTF_16_SURROGATE (coding) = surrogate = 0;
1729                  *charbuf++ = 0x10000 + c;
1730                }
1731            }
1732          else
1733            {
1734              if (UTF_16_HIGH_SURROGATE_P (c))
1735                CODING_UTF_16_SURROGATE (coding) = surrogate = c;
1736              else
1737                {
1738                  if (eol_crlf && c == '\r')
1739                    {
1740                      ONE_MORE_BYTE (byte_after_cr1);
1741                      ONE_MORE_BYTE (byte_after_cr2);
1742                    }
1743                  *charbuf++ = c;
1744                }
1745            }
1746        }
1747    
1748     no_more_source:

Event uninit_use: Using uninitialized value "consumed_chars_base"
Also see events: [var_decl]

1749      coding->consumed_char += consumed_chars_base;
1750      coding->consumed = src_base - coding->source;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]