Bug 62505 - Remove unnecessary strlen from DocumentWriter
Summary: Remove unnecessary strlen from DocumentWriter
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Adam Barth
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-11 19:02 PDT by Adam Barth
Modified: 2011-06-11 22:09 PDT (History)
2 users (show)

See Also:


Attachments
Patch (3.92 KB, patch)
2011-06-11 19:04 PDT, Adam Barth
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Barth 2011-06-11 19:02:42 PDT
Remove unnecessary strlen from DocumentWriter
Comment 1 Adam Barth 2011-06-11 19:04:40 PDT
Created attachment 96869 [details]
Patch
Comment 2 Darin Adler 2011-06-11 20:42:11 PDT
Comment on attachment 96869 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=96869&action=review

> Source/WebCore/loader/DocumentWriter.cpp:204
> -void DocumentWriter::addData(const char* bytes, int length)
> +void DocumentWriter::addData(const char* bytes, size_t length)
>  {
> -    if (length == -1)
> -        length = strlen(bytes);
> -
>      m_parser->appendBytes(this, bytes, length);
>  }

This function now truncates a passed-in size_t to an int by passing it to appendBytes.

It would be possible to instead write a loop that does up to INT_MAX characters at once. Or to make a more extensive change so we use size_t in the signature of the appendBytes function too.
Comment 3 WebKit Review Bot 2011-06-11 21:19:51 PDT
Comment on attachment 96869 [details]
Patch

Clearing flags on attachment: 96869

Committed r88610: <http://trac.webkit.org/changeset/88610>
Comment 4 WebKit Review Bot 2011-06-11 21:19:55 PDT
All reviewed patches have been landed.  Closing bug.
Comment 5 Adam Barth 2011-06-11 22:09:06 PDT
> It would be possible to instead write a loop that does up to INT_MAX characters at once. Or to make a more extensive change so we use size_t in the signature of the appendBytes function too.

It seems like we should just use size_t everywhere for the length of the buffer.  There's a bunch of code sites that need to change.  I'll study it.