[Webkit-unassigned] [Bug 37222] [WINCE] Port SharedBuffer

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon May 10 08:56:23 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=37222


Adam Roben (aroben) <aroben at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #55554|review?, commit-queue?      |review-
               Flag|                            |




--- Comment #13 from Adam Roben (aroben) <aroben at apple.com>  2010-05-10 08:56:22 PST ---
(From update of attachment 55554)
> +    Vector<char> buffer;
> +    DWORD bytesToRead = GetFileSize(fileHandle, 0);
> +    DWORD lastError = GetLastError();
>  
> -    // Stat the file to get its size
> -    struct _stat64 fileStat;
> -    if (_fstat64(_fileno(fileDescriptor), &fileStat))
> -        goto exit;
> +    if (bytesToRead != INVALID_FILE_SIZE || lastError == NO_ERROR) {
> +        DWORD bytesRead;
> +        if (!ReadFile(fileHandle, buffer.data(), bytesToRead, &bytesRead, 0) || bytesToRead != bytesRead)

You're using buffer.data() here without setting buffer's size.

I'd suggest structuring things like this:

RefPtr<SharedBuffer> result;
DWORD bytesToRead = GetFileSize(fileHandle, 0);

if (bytesToRead != INVALID_FILE_SIZE || lastError == NO_ERROR) {
    Vector<char> buffer(bytesToRead);
    if (!ReadFile(...) || bytesToRead != bytesRead)
        LOG_ERROR(...);
    else
        result = SharedBuffer::adoptVector(buffer);
} else
    LOG_ERROR(...);

CloseHandle(fileHandle);
return result.release();

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list