Changeset f2d2c7ba in mainline


Ignore:
Timestamp:
2009-04-21T16:36:52Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
253d3d0
Parents:
c2417bc
Message:

fix of-by-one-character bug in str_chr() and str_rchr()

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/lib/string.c

    rc2417bc rf2d2c7ba  
    642642        wchar_t acc;
    643643        size_t off = 0;
     644        size_t last = 0;
    644645       
    645646        while ((acc = str_decode(str, &off, STR_NO_LIMIT)) != 0) {
    646647                if (acc == ch)
    647                         return (str + off);
     648                        return (str + last);
     649                last = off;
    648650        }
    649651       
  • uspace/lib/libc/generic/string.c

    rc2417bc rf2d2c7ba  
    594594        wchar_t acc;
    595595        size_t off = 0;
     596        size_t last = 0;
    596597       
    597598        while ((acc = str_decode(str, &off, STR_NO_LIMIT)) != 0) {
    598599                if (acc == ch)
    599                         return (str + off);
     600                        return (str + last);
     601                last = off;
    600602        }
    601603       
     
    614616        wchar_t acc;
    615617        size_t off = 0;
    616         char *res;
    617 
    618         res = NULL;
     618        size_t last = 0;
     619        char *res = NULL;
     620       
    619621        while ((acc = str_decode(str, &off, STR_NO_LIMIT)) != 0) {
    620622                if (acc == ch)
    621                         res = (str + off);
    622         }
    623 
     623                        res = (str + last);
     624                last = off;
     625        }
     626       
    624627        return res;
    625628}
Note: See TracChangeset for help on using the changeset viewer.