gnash-commit
[Top][All Lists]
Advanced

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

Re: [Gnash-commit] /srv/bzr/gnash/trunk r11346: TextField.restrict


From: Benjamin Wolsey
Subject: Re: [Gnash-commit] /srv/bzr/gnash/trunk r11346: TextField.restrict
Date: Fri, 07 Aug 2009 11:44:20 +0200

> -    //TODO: implement ranges, like (A-Z a-z);
> +    if (*rit == '^') { //then this is a true RESTRICT pattern, add all chars 
> to _restrictedchars
> +        for (unsigned int i = 0; i <= 255; ++i) {
> +            _restrictedchars.insert(char(i));

char(255) can produce -1 if the C++ implementation's standard char type
is signed. This is usually the case.

> +        }

ActionScript handles 65535 unicode characters, not just the 255 extended
ascii ones. This is an inventive way of implementing it, but it may be
more accurate to parse the restrict string on each key-stroke, and not
assign a large amount of memory for the container and its information.

>        
>      while (rit != re) {
>          while (rit != re && *rit != '^') { //This loop allows chars
> -            if (*rit != '\\') {
> +            if (*rit == '-') {
> +                log_error("invalid restrict string");
> +                return;
> +            } else if (*(rit+1) == '-') {
> +                if (re - (rit+2) != 0) {

You haven't checked how far away the end is, so these potentially
dereference an invalid iterator.

> +                    ++rit;
> +                    ++rit;
> +                    ++rit;

rit += 3;

or (for handling non-random-access iterators):

std::advance(rit, 3);

--
Free Flash, use Gnash
http://www.gnu.org/software/gnash/

Benjamin Wolsey, Software Developer - http://benjaminwolsey.de

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


reply via email to

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