Skip to content

Commit e678f9a

Browse files
cocoaui, pltbrowser: fix int overflow bug resulting in negative values in total playback time calculation (fixes #3270)
1 parent fcaea15 commit e678f9a

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

plugins/cocoaui/DesignMode/Widgets/PlaylistBrowser/PlaylistBrowserViewController.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,10 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn
270270
}
271271
else if ([tableColumn.identifier isEqualToString:@"Duration"]) {
272272
float pl_totaltime = deadbeef->plt_get_totaltime (plt);
273-
int daystotal = (int)pl_totaltime / (3600*24);
274-
int hourtotal = ((int)pl_totaltime / 3600) % 24;
275-
int mintotal = ((int)pl_totaltime/60) % 60;
276-
int sectotal = ((int)pl_totaltime) % 60;
273+
int daystotal = (int)(int64_t)pl_totaltime / (3600 * 24);
274+
int hourtotal = (int)((int64_t)pl_totaltime / 3600) % 24;
275+
int mintotal = (int)((int64_t)pl_totaltime / 60) % 60;
276+
int sectotal = (int)((int64_t)pl_totaltime) % 60;
277277

278278
char totaltime_str[512] = "";
279279
if (daystotal == 0) {

plugins/cocoaui/MainWindowController.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ - (void)updateSonginfo {
205205
char sbtext_new[512] = "-";
206206

207207
float pl_totaltime = roundf(deadbeef->pl_get_totaltime ());
208-
int daystotal = (int)pl_totaltime / (3600*24);
209-
int hourtotal = ((int)pl_totaltime / 3600) % 24;
210-
int mintotal = ((int)pl_totaltime/60) % 60;
211-
int sectotal = ((int)pl_totaltime) % 60;
208+
int daystotal = (int)(int64_t)pl_totaltime / (3600 * 24);
209+
int hourtotal = (int)((int64_t)pl_totaltime / 3600) % 24;
210+
int mintotal = (int)((int64_t)pl_totaltime / 60) % 60;
211+
int sectotal = (int)((int64_t)pl_totaltime) % 60;
212212

213213
char totaltime_str[512] = "";
214214
if (daystotal == 0) {

plugins/pltbrowser/pltbrowser.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,10 @@ fill_pltbrowser_rows (gpointer user_data)
203203
snprintf (num_items_str, sizeof (num_items_str), "%d", num_items);
204204

205205
float pl_totaltime = deadbeef->plt_get_totaltime (plt);
206-
int daystotal = (int)pl_totaltime / (3600*24);
207-
int hourtotal = ((int)pl_totaltime / 3600) % 24;
208-
int mintotal = ((int)pl_totaltime/60) % 60;
209-
int sectotal = ((int)pl_totaltime) % 60;
206+
int daystotal = (int)(int64_t)pl_totaltime / (3600 * 24);
207+
int hourtotal = (int)((int64_t)pl_totaltime / 3600) % 24;
208+
int mintotal = (int)((int64_t)pl_totaltime / 60) % 60;
209+
int sectotal = (int)((int64_t)pl_totaltime) % 60;
210210

211211
char totaltime_str[512] = "";
212212
if (daystotal == 0) {

0 commit comments

Comments
 (0)