Skip to content

Commit 16b6791

Browse files
committed
修复深度审计发现的3个问题:BestSource除零、wxImage重复分配、格式字符串
- video_provider_bestsource: GetDAR()除零保护,分母为零时返回0 - libresrc: DPI缩放中移除wxImage重复分配 - audio_player_pulse: 移除冗余printf格式字符串转换
1 parent 3df0a3f commit 16b6791

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/command/video.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,8 @@ namespace {
651651
}
652652
}
653653

654-
wxImage::AddHandler(new wxJPEGHandler);
654+
if (!wxImage::FindHandler(wxBITMAP_TYPE_JPEG))
655+
wxImage::AddHandler(new wxJPEGHandler);
655656
// 如果HDR色彩映射已启用,对图片序列导出帧应用CPU侧LUT色彩映射
656657
const bool seq_hdr_enabled = OPT_GET("Video/HDR/Tone Mapping")->GetBool();
657658
const HDRType seq_hdr_type = c->project->VideoProvider()->GetHDRType();
@@ -988,7 +989,8 @@ namespace {
988989
wxBitmapType image_type = wxBITMAP_TYPE_PNG;
989990
wxImage img = get_image(c, raw, subsonly);
990991
if (image_suffix == "jpg") {
991-
wxImage::AddHandler(new wxJPEGHandler);
992+
if (!wxImage::FindHandler(wxBITMAP_TYPE_JPEG))
993+
wxImage::AddHandler(new wxJPEGHandler);
992994
img.SetOption(wxIMAGE_OPTION_QUALITY, 100);
993995
image_type = wxBITMAP_TYPE_JPEG;
994996
}

src/video_provider_bestsource.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ class BSVideoProvider final : public VideoProvider {
8787
int GetHeight() const override { return properties.Height + paddingTop + paddingBottom; };
8888
double GetDAR() const override {
8989
const int totalH = properties.Height + paddingTop + paddingBottom;
90-
return ((double) properties.Width * properties.SAR.Num) / (totalH * properties.SAR.Den);
90+
if (properties.SAR.Den > 0 && properties.SAR.Num > 0 && totalH > 0)
91+
return ((double) properties.Width * properties.SAR.Num) / (totalH * properties.SAR.Den);
92+
return (totalH > 0) ? (double) properties.Width / totalH : 0;
9193
};
9294

9395
agi::vfr::Framerate GetFPS() const override { return Timecodes; };
@@ -249,7 +251,7 @@ BSVideoProvider::BSVideoProvider(agi::fs::path const& filename, std::string cons
249251
}
250252
}
251253
catch (BestSourceException const& err) {
252-
throw VideoOpenError(agi::format("Failed to create BestVideoSource: %s", + err.what()));
254+
throw VideoOpenError(agi::format("Failed to create BestVideoSource: %s", err.what()));
253255
}
254256

255257
void BSVideoProvider::GetFrame(int n, VideoFrame &out) {

0 commit comments

Comments
 (0)