Commit 3d03ccf2 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Fixed report_data for recursive calls.

parent 6927eecd
...@@ -703,7 +703,7 @@ static HRESULT WINAPI ProtocolHandler_Read(IInternetProtocol *iface, void *pv, ...@@ -703,7 +703,7 @@ static HRESULT WINAPI ProtocolHandler_Read(IInternetProtocol *iface, void *pv,
TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead); TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
if(This->buf) { if(This->buf_size) {
read = min(cb, This->buf_size); read = min(cb, This->buf_size);
memcpy(pv, This->buf, read); memcpy(pv, This->buf, read);
...@@ -1028,37 +1028,52 @@ static HRESULT report_data(BindProtocol *This, DWORD bscf, ULONG progress, ULONG ...@@ -1028,37 +1028,52 @@ static HRESULT report_data(BindProtocol *This, DWORD bscf, ULONG progress, ULONG
return S_OK; return S_OK;
if((This->pi & PI_MIMEVERIFICATION) && !This->reported_mime) { if((This->pi & PI_MIMEVERIFICATION) && !This->reported_mime) {
BYTE buf[BUFFER_SIZE];
DWORD read = 0; DWORD read = 0;
LPWSTR mime; LPWSTR mime;
HRESULT hres; HRESULT hres;
if(!This->buf) {
This->buf = heap_alloc(BUFFER_SIZE);
if(!This->buf)
return E_OUTOFMEMORY;
}
do { do {
read = 0; read = 0;
hres = IInternetProtocol_Read(This->protocol, This->buf+This->buf_size, hres = IInternetProtocol_Read(This->protocol, buf,
BUFFER_SIZE-This->buf_size, &read); sizeof(buf)-This->buf_size, &read);
if(FAILED(hres) && hres != E_PENDING) if(FAILED(hres) && hres != E_PENDING)
return hres; return hres;
if(!This->buf) {
This->buf = heap_alloc(BUFFER_SIZE);
if(!This->buf)
return E_OUTOFMEMORY;
}else if(read + This->buf_size > BUFFER_SIZE) {
BYTE *tmp;
tmp = heap_realloc(This->buf, read+This->buf_size);
if(!tmp)
return E_OUTOFMEMORY;
This->buf = tmp;
}
memcpy(This->buf+This->buf_size, buf, read);
This->buf_size += read; This->buf_size += read;
}while(This->buf_size < MIME_TEST_SIZE && hres == S_OK); }while(This->buf_size < MIME_TEST_SIZE && hres == S_OK);
if(This->buf_size < MIME_TEST_SIZE && hres != S_FALSE) if(This->buf_size < MIME_TEST_SIZE && hres != S_FALSE)
return S_OK; return S_OK;
hres = FindMimeFromData(NULL, This->url, This->buf, min(This->buf_size, MIME_TEST_SIZE), if(!This->reported_mime) {
This->mime, 0, &mime, 0); hres = FindMimeFromData(NULL, This->url, This->buf, min(This->buf_size, MIME_TEST_SIZE),
if(FAILED(hres)) This->mime, 0, &mime, 0);
return hres; if(FAILED(hres))
return hres;
mime_available(This, mime, TRUE); mime_available(This, mime, TRUE);
CoTaskMemFree(mime); CoTaskMemFree(mime);
}
} }
if(!This->protocol_sink)
return S_OK;
return IInternetProtocolSink_ReportData(This->protocol_sink, bscf, progress, progress_max); return IInternetProtocolSink_ReportData(This->protocol_sink, bscf, progress, progress_max);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment