mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
TakeSourceScreenshot: fix heap corruption on windows
This commit is contained in:
parent
f10c0d2558
commit
059244bb32
@ -1369,7 +1369,7 @@ HandlerResponse WSRequestHandler::HandleTakeSourceScreenshot(WSRequestHandler* r
|
|||||||
|
|
||||||
const char* pictureFormat = obs_data_get_string(req->data, "pictureFormat");
|
const char* pictureFormat = obs_data_get_string(req->data, "pictureFormat");
|
||||||
|
|
||||||
auto supportedFormats = QImageWriter::supportedImageFormats();
|
QByteArrayList supportedFormats = QImageWriter::supportedImageFormats();
|
||||||
if (!supportedFormats.contains(pictureFormat)) {
|
if (!supportedFormats.contains(pictureFormat)) {
|
||||||
QString errorMessage = QString("Unsupported picture format: %1").arg(pictureFormat);
|
QString errorMessage = QString("Unsupported picture format: %1").arg(pictureFormat);
|
||||||
return req->SendErrorResponse(errorMessage.toUtf8());
|
return req->SendErrorResponse(errorMessage.toUtf8());
|
||||||
@ -1412,7 +1412,7 @@ HandlerResponse WSRequestHandler::HandleTakeSourceScreenshot(WSRequestHandler* r
|
|||||||
bool renderSuccess = false;
|
bool renderSuccess = false;
|
||||||
gs_texrender_reset(texrender);
|
gs_texrender_reset(texrender);
|
||||||
if (gs_texrender_begin(texrender, imgWidth, imgHeight)) {
|
if (gs_texrender_begin(texrender, imgWidth, imgHeight)) {
|
||||||
struct vec4 background;
|
vec4 background;
|
||||||
vec4_zero(&background);
|
vec4_zero(&background);
|
||||||
|
|
||||||
gs_clear(GS_CLEAR_COLOR, &background, 0.0f, 0);
|
gs_clear(GS_CLEAR_COLOR, &background, 0.0f, 0);
|
||||||
@ -1428,7 +1428,10 @@ HandlerResponse WSRequestHandler::HandleTakeSourceScreenshot(WSRequestHandler* r
|
|||||||
|
|
||||||
gs_stage_texture(stagesurface, gs_texrender_get_texture(texrender));
|
gs_stage_texture(stagesurface, gs_texrender_get_texture(texrender));
|
||||||
if (gs_stagesurface_map(stagesurface, &videoData, &videoLinesize)) {
|
if (gs_stagesurface_map(stagesurface, &videoData, &videoLinesize)) {
|
||||||
memcpy(sourceImage.bits(), videoData, videoLinesize * imgHeight);
|
int linesize = sourceImage.bytesPerLine();
|
||||||
|
for (int y = 0; y < imgHeight; y++) {
|
||||||
|
memcpy(sourceImage.scanLine(y), videoData + (y * linesize), linesize);
|
||||||
|
}
|
||||||
gs_stagesurface_unmap(stagesurface);
|
gs_stagesurface_unmap(stagesurface);
|
||||||
renderSuccess = true;
|
renderSuccess = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user