This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: PR preprocessor/36479: Short buffer in libcpp


Hi,

narrow_cset_desc.width is  initialized in cpp_init_iconv
only when charset conversion is requested.
cpp_interpret_string_notranslate doesn't set
narrow_cset_desc.width when it initializes
narrow_cset_desc.  This patch also seems to work
for me.


H.J.
---
2008-06-09  H.J. Lu  <hongjiu.lu@intel.com>

	PR preprocessor/36479
	* charset.c (cpp_interpret_string_notranslate): Also set
	narrow_cset_desc.width.

On Mon, Jun 9, 2008 at 1:19 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> cvt is return from
>
> (gdb) step
> converter_for_type (pfile=0x1059480, type=CPP_STRING)
>    at /net/gnu-13/export/gnu/src/gcc/gcc/libcpp/charset.c:1329
> 1329      switch (type)
>
> static struct cset_converter
> converter_for_type (cpp_reader *pfile, enum cpp_ttype type)
> {
>  switch (type)
>    {
>    default:
>        return pfile->narrow_cset_desc;
>    case CPP_CHAR16:
>    case CPP_STRING16:
>        return pfile->char16_cset_desc;
>    case CPP_CHAR32:
>    case CPP_STRING32:
>        return pfile->char32_cset_desc;
>    case CPP_WCHAR:
>    case CPP_WSTRING:
>        return pfile->wide_cset_desc;
>    }
> }
>
> It is set from
>
>  pfile->narrow_cset_desc = init_iconv_desc (pfile, ncset, SOURCE_CHARSET);
>  pfile->narrow_cset_desc.width = CPP_OPTION (pfile, char_precision);
>
> It may be related to
>
> http://gcc.gnu.org/ml/gcc-patches/2008-04/msg01235.html
>
> H.J.
> --
> On Mon, Jun 9, 2008 at 12:36 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>>> "H.J." == H J Lu <hjl.tools@gmail.com> writes:
>>
>> H.J.>   PR preprocessor/36479
>> H.J.>   * charset.c (emit_numeric_escape): Handle 0 width.
>>
>> When can width be 0?
>>
>> This looks like PR 36379 now.
>>
>> I suspect perhaps some fallout from the recent patch for cpp-ization
>> of gfortran.  Though, that is just a guess.
>>
>> Tom
>>
>

Attachment: libcpp-buf-3.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]