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]; char temp[TEMPSIZE];
double time_mm, time_ss; double time_mm, time_ss;
desc[0] = '\0';
if (!vgmstream) { if (!vgmstream) {
snprintf(temp,TEMPSIZE, "NULL VGMSTREAM"); snprintf(temp,TEMPSIZE, "NULL VGMSTREAM");
concatn(length,desc,temp); concatn(length,desc,temp);

View File

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