Merge lp:~victored/noise/lp-1431042 into lp:~elementary-apps/noise/trunk

Proposed by Victor Martinez
Status: Merged
Approved by: Danielle Foré
Approved revision: 1787
Merged at revision: 1789
Proposed branch: lp:~victored/noise/lp-1431042
Merge into: lp:~elementary-apps/noise/trunk
Diff against target: 31 lines (+8/-6)
1 file modified
src/PlaybackManager.vala (+8/-6)
To merge this branch: bzr merge lp:~victored/noise/lp-1431042
Reviewer Review Type Date Requested Status
Danielle Foré Approve
Review via email: mp+253789@code.launchpad.net

Commit message

Make sure only valid item indexes are accessed when shuffling media. Fixes lp:1431042

Description of the change

This branch corrects the code flaw that leads to the segmentation fault. Fixes lp:1431042

To post a comment you must log in.
Revision history for this message
Victor Martinez (victored) wrote :

Crash origin:

Revision history for this message
Danielle Foré (danrabbit) wrote :

Trying real hard to crash noise with next/previous toggling shuffle on and off. Can't do it :p

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/PlaybackManager.vala'
2--- src/PlaybackManager.vala 2015-03-10 00:20:38 +0000
3+++ src/PlaybackManager.vala 2015-03-23 04:55:37 +0000
4@@ -61,9 +61,8 @@
5 // TODO: REWRITE IT USING THE LIBRARY
6 public Library library { get { return libraries_manager.local_library; } }
7
8- public int _played_index = 0;//if user press back, this goes back 1 until it hits 0. as new media play, this goes with it
9- public int _current_index;
10- public int _current_shuffled_index;
11+ private int _current_index;
12+ private int _current_shuffled_index;
13
14 public bool playing { get; private set; default = false; }
15 private double saved_volume = 1;
16@@ -254,9 +253,12 @@
17 //and set that int i as one of those this is confusing just a sort
18 //_current_shuffled.set(0, current_media.rowid);
19 for(int i = 1;i < _current.size; ++i) {
20- int random = GLib.Random.int_range(0, temp.size);
21-
22- //if(temp.get(random) != current_media.rowid) {
23+ int n_media = temp.size;
24+ if (n_media == 0)
25+ break;
26+
27+ int random = n_media <= 1 ? 0 : Random.int_range (0, n_media - 1);
28+
29 if(current_media != null && temp.get(random) == current_media) {
30 _current_shuffled.set(0, current_media);
31 --i;

Subscribers

People subscribed via source and target branches