Bug 692347 - "Assertion failed! (unsigned)(c + 1) <= 256" with extended chars in GS_OPTIONS
Summary: "Assertion failed! (unsigned)(c + 1) <= 256" with extended chars in GS_OPTIONS
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: General (show other bugs)
Version: master
Hardware: PC Windows XP
: P4 normal
Assignee: Default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-16 19:01 UTC by SaGS
Modified: 2011-07-29 18:52 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
Suggested patch. (517 bytes, patch)
2011-07-16 19:03 UTC, SaGS
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description SaGS 2011-07-16 19:01:33 UTC
The following sequence of commands:

    set GS_OPTIONS=-dMéditéranéen
    gswin32c

leads to:

    Debug Assertion failed!
    File: isctype.c [this one is from the C RunTime, not from GS]
    Expression: (unsigned)(c + 1) <= 256

Ghostscript compiled on Windows using Visual Studio .NET 2003.

Cause:

    VS treats the "char" type as signed by default. This means 
    that when extended characters are promoted to ints, the values
    are negative in the range -128 to -1. These values (except -1
    which conflicts with EOF) are not valid for the "is*()" family 
    of functions. GS does exhibit this problem while parsing the
    GS_OPTIONS. Not sure if this can ever happen with command line 
    arguments or @files.

This does not seem to be a regression, the SVN history shows the 
affected part as being from revision 2 (but it is older for sure).
Comment 1 SaGS 2011-07-16 19:03:07 UTC
Created attachment 7678 [details]
Suggested patch.

Bug 692347: "Assertion failed! (unsigned)(c + 1) <= 256" with extended chars in GS_OPTIONS.

In some circumstances, characters from the arguments are passed to
"isspace()", which expects an int argument in the rage 0..255 or the
value EOF. In the char type is signed, character values of 128 and
larger are considered negative, and promoted to negative integers
outside the range accepted by "isspace()".
Comment 2 Alex Cherepanov 2011-07-29 18:52:43 UTC
This patch has been committed by Ray on 2011-07-17 as a rev.
44a2fd0bb1e2dd12e9ba475da0bdbb93081325d5