Merge pull request #938 from NicknineTheEagle/desc-fix

Properly initialize input buffer in describe_vgmstream
This commit is contained in:
NicknineTheEagle 2021-09-01 02:21:44 +03:00 committed by GitHub
commit dc7b82cd9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 13 deletions

View File

@ -911,6 +911,8 @@ void describe_vgmstream(VGMSTREAM* vgmstream, char* desc, int length) {
char temp[TEMPSIZE];
double time_mm, time_ss;
desc[0] = '\0';
if (!vgmstream) {
snprintf(temp,TEMPSIZE, "NULL VGMSTREAM");
concatn(length,desc,temp);

View File

@ -539,17 +539,15 @@ void winamp_SetPan(int pan) {
/* display info box (ALT+3) */
int winamp_InfoBox(const in_char *fn, HWND hwnd) {
char description[1024] = {0}, tmp[1024] = {0};
size_t description_size = 1024;
TCHAR tbuf[1024] = {0};
double tmpVolume = 1.0;
concatn(description_size,description,PLUGIN_INFO "\n\n");
if (!fn || !*fn) {
/* no filename = current playing file */
if (!vgmstream)
return 0;
describe_vgmstream(vgmstream,description,description_size);
describe_vgmstream(vgmstream,description,sizeof(description));
}
else {
/* some other file in playlist given by filename */
@ -569,24 +567,21 @@ int winamp_InfoBox(const in_char *fn, HWND hwnd) {
vgmstream_mixing_autodownmix(infostream, settings.downmix_channels);
vgmstream_mixing_enable(infostream, 0, NULL, NULL);
describe_vgmstream(infostream,description,description_size);
describe_vgmstream(infostream,description,sizeof(description));
close_vgmstream(infostream);
infostream = NULL;
tmpVolume = get_album_gain_volume(fn);
}
snprintf(tmp, sizeof(tmp), "\nvolume: %.6f\n", tmpVolume);
concatn(sizeof(description), description, tmp);
{
TCHAR buf[1024] = {0};
size_t buf_size = 1024;
concatn(sizeof(description), description, "\n" PLUGIN_INFO);
snprintf(tmp, sizeof(tmp), "\nvolume: %.6f", tmpVolume);
concatn(description_size, description, tmp);
cfg_char_to_wchar(tbuf, sizeof(tbuf) / sizeof(TCHAR), description);
MessageBox(hwnd, tbuf, TEXT("Stream info"), MB_OK);
cfg_char_to_wchar(buf, buf_size, description);
MessageBox(hwnd,buf,TEXT("Stream info"),MB_OK);
}
return 0;
}