(svn r6793) -Fix(5464): When checking items on an array, make sure to respect boundaries(jez).

Made some comments code style compliant
pull/155/head
belugas 18 years ago
parent 6b5c105e28
commit 6ad7878fb2

@ -49,14 +49,11 @@ static void SkipToPrevSong(void)
byte *p = b; byte *p = b;
byte t; byte t;
// empty playlist if (b[0] == 0) return; // empty playlist
if (b[0] == 0) return;
// find the end do p++; while (p[0] != 0); // find the end
do p++; while (p[0] != 0);
// and copy the bytes t = *--p; // and copy the bytes
t = *--p;
while (p != b) { while (p != b) {
p--; p--;
p[1] = p[0]; p[1] = p[0];
@ -109,13 +106,16 @@ static void SelectSongToPlay(void)
memset(_cur_playlist, 0, sizeof(_cur_playlist)); memset(_cur_playlist, 0, sizeof(_cur_playlist));
do { do {
snprintf(filename, sizeof(filename), "%s%s", if (_playlists[msf.playlist][i] != 0) { // Don't evaluate playlist terminator
_path.gm_dir, origin_songs_specs[_playlists[msf.playlist][i]].filename); snprintf(filename, sizeof(filename), "%s%s",
//we are now checking for the existence of that file prior _path.gm_dir, origin_songs_specs[(_playlists[msf.playlist][i]) - 1].filename);
//to add it to the list of available songs
if (FileExists(filename)) { /* we are now checking for the existence of that file prior
_cur_playlist[j] = _playlists[msf.playlist][i]; * to add it to the list of available songs */
j++; if (FileExists(filename)) {
_cur_playlist[j] = _playlists[msf.playlist][i];
j++;
}
} }
} while (_playlists[msf.playlist][i++] != 0 && i < lengthof(_cur_playlist) - 1); } while (_playlists[msf.playlist][i++] != 0 && i < lengthof(_cur_playlist) - 1);
@ -147,9 +147,9 @@ static void PlayPlaylistSong(void)
{ {
if (_cur_playlist[0] == 0) { if (_cur_playlist[0] == 0) {
SelectSongToPlay(); SelectSongToPlay();
//if there is not songs in the playlist, it may indicate /* if there is not songs in the playlist, it may indicate
//no file on the gm folder, or even no gm folder. * no file on the gm folder, or even no gm folder.
//Stop the playback, then * Stop the playback, then */
if (_cur_playlist[0] == 0) { if (_cur_playlist[0] == 0) {
_song_is_active = false; _song_is_active = false;
_music_wnd_cursong = 0; _music_wnd_cursong = 0;
@ -241,7 +241,7 @@ static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e)
case WE_CLICK: case WE_CLICK:
switch (e->we.click.widget) { switch (e->we.click.widget) {
case 3: { /* add to playlist */ case 3: { // add to playlist
int y = (e->we.click.pt.y - 23) / 6; int y = (e->we.click.pt.y - 23) / 6;
uint i; uint i;
byte *p; byte *p;
@ -261,7 +261,7 @@ static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e)
} }
} break; } break;
case 4: { /* remove from playlist */ case 4: { // remove from playlist
int y = (e->we.click.pt.y - 23) / 6; int y = (e->we.click.pt.y - 23) / 6;
uint i; uint i;
byte *p; byte *p;
@ -278,7 +278,7 @@ static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e)
SelectSongToPlay(); SelectSongToPlay();
} break; } break;
case 11: /* clear */ case 11: // clear
_playlists[msf.playlist][0] = 0; _playlists[msf.playlist][0] = 0;
SetWindowDirty(w); SetWindowDirty(w);
StopMusic(); StopMusic();
@ -286,7 +286,7 @@ static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e)
break; break;
#if 0 #if 0
case 12: /* save */ case 12: // save
ShowInfo("MusicTrackSelectionWndProc:save not implemented\n"); ShowInfo("MusicTrackSelectionWndProc:save not implemented\n");
break; break;
#endif #endif

Loading…
Cancel
Save