[LLVMbugs] [Bug 8460] New: Assert for missing NULL caused by bad erase call

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Oct 25 12:53:15 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=8460

           Summary: Assert for missing NULL caused by bad erase call
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P
         Component: System Library
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: jim at thegoodnows.net
                CC: llvmbugs at cs.uiuc.edu


In lib/System/Win32/Path.inc, function Path::isValid(), a null terminator is
added to the path being checked. At one point, a trailing slash is detected and
removed using:

path.erase(--len);

However, since a null has been added, this call erases the null as well. There
are really two issues here. First, the call should be:

path.erase(--len, 1);

to just erase the trailing slash.

The second issue is that the logic of the function is a bit awkward since the
len is calculated before the null is added, so doing checks like:

path[len-1] == '/'

make it seem like the slash is really the last character. A better approach
might be to take the length after the null is added and then the check would
become:

path[len-2] == '/'

which would make it clearer that you can't erase to the end.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list