[banshee] [Mtp] Fix overflow bug with playlists (bgo#628388)
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [Mtp] Fix overflow bug with playlists (bgo#628388)
- Date: Wed, 1 Sep 2010 03:44:17 +0000 (UTC)
commit 433488d3ff738cf516f1aba4eae5f6474f84d8d6
Author: Gabriel Burt <gabriel burt gmail com>
Date: Tue Aug 31 22:43:17 2010 -0500
[Mtp] Fix overflow bug with playlists (bgo#628388)
.../Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs | 4 +-
src/Libraries/Mtp/Mtp/AbstractTrackList.cs | 26 ++++++++++----------
2 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs b/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
index 08317cf..ac8ea71 100644
--- a/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
+++ b/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
@@ -193,7 +193,7 @@ namespace Banshee.Dap.Mtp
PlaylistSource pl_src = new PlaylistSource (playlist.Name, this);
pl_src.Save ();
// TODO a transaction would make sense here (when the threading issue is fixed)
- foreach (int id in playlist.TrackIds) {
+ foreach (uint id in playlist.TrackIds) {
ServiceManager.DbConnection.Execute (insert_cmd, pl_src.DbId, this.DbId, id);
}
pl_src.UpdateCounts ();
@@ -240,7 +240,7 @@ namespace Banshee.Dap.Mtp
PlaylistSource from = child as PlaylistSource;
if (from != null && from.Count > 0) {
MTP.Playlist playlist = new MTP.Playlist (mtp_device, from.Name);
- foreach (int track_id in ServiceManager.DbConnection.QueryEnumerable<int> (String.Format (
+ foreach (uint track_id in ServiceManager.DbConnection.QueryEnumerable<uint> (String.Format (
"SELECT CoreTracks.ExternalID FROM {0} WHERE {1}",
from.DatabaseTrackModel.ConditionFromFragment, from.DatabaseTrackModel.Condition)))
{
diff --git a/src/Libraries/Mtp/Mtp/AbstractTrackList.cs b/src/Libraries/Mtp/Mtp/AbstractTrackList.cs
index 976470f..53a54eb 100644
--- a/src/Libraries/Mtp/Mtp/AbstractTrackList.cs
+++ b/src/Libraries/Mtp/Mtp/AbstractTrackList.cs
@@ -7,7 +7,7 @@ namespace Mtp
public abstract class AbstractTrackList
{
private bool saved;
- private List<int> track_ids;
+ private List<uint> track_ids;
private MtpDevice device;
public abstract uint Count { get; protected set; }
@@ -20,14 +20,14 @@ namespace Mtp
public bool Saved { get { return saved; } }
protected MtpDevice Device { get { return device; } }
- public IList<int> TrackIds {
+ public IList<uint> TrackIds {
get { return track_ids; }
}
public AbstractTrackList (MtpDevice device, string name)
{
this.device = device;
- track_ids = new List<int> ();
+ track_ids = new List<uint> ();
}
internal AbstractTrackList (MtpDevice device, IntPtr tracks, uint count)
@@ -36,20 +36,20 @@ namespace Mtp
this.saved = true;
if (tracks != IntPtr.Zero) {
- int [] vals = new int [count];
- Marshal.Copy ((IntPtr)tracks, (int[])vals, 0, (int)count);
- track_ids = new List<int> (vals);
+ var vals = new uint [count];
+ Marshal.Copy ((IntPtr)tracks, (int[])(object)vals, 0, (int)count);
+ track_ids = new List<uint> (vals);
} else {
- track_ids = new List<int> ();
+ track_ids = new List<uint> ();
}
}
public void AddTrack (Track track)
{
- AddTrack ((int)track.FileId);
+ AddTrack (track.FileId);
}
- public void AddTrack (int track_id)
+ public void AddTrack (uint track_id)
{
track_ids.Add (track_id);
Count++;
@@ -57,10 +57,10 @@ namespace Mtp
public void RemoveTrack (Track track)
{
- RemoveTrack ((int)track.FileId);
+ RemoveTrack (track.FileId);
}
- public void RemoveTrack (int track_id)
+ public void RemoveTrack (uint track_id)
{
track_ids.Remove (track_id);
Count--;
@@ -84,8 +84,8 @@ namespace Mtp
if (Count == 0) {
TracksPtr = IntPtr.Zero;
} else {
- TracksPtr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (int)) * (int)Count);
- Marshal.Copy (track_ids.ToArray (), 0, TracksPtr, (int)Count);
+ TracksPtr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (uint)) * (int)Count);
+ Marshal.Copy ((int[])(object)track_ids.ToArray (), 0, TracksPtr, (int)Count);
}
if (saved) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]