summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTeruaki Kawashima <teru@rockbox.org>2010-07-06 13:46:32 +0000
committerTeruaki Kawashima <teru@rockbox.org>2010-07-06 13:46:32 +0000
commit851e06617bd3d4ec5427226b49e13ab2efba0cad (patch)
tree1431c73e36ac5f4692362a39c83075a7c08a41d2 /apps
parent079e19491aa5a49d4ee992022601afde20ec0287 (diff)
downloadrockbox-851e06617bd3d4ec5427226b49e13ab2efba0cad.tar.gz
rockbox-851e06617bd3d4ec5427226b49e13ab2efba0cad.zip
lrcplayer:
* fix possible infinite loop in save_changes(). hopefully fix FS#11457. * use .lrc file instead of .lrc8 file when saveing changes to the lyrics read from id3 tag. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27305 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/lrcplayer.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/apps/plugins/lrcplayer.c b/apps/plugins/lrcplayer.c
index 10af855d6c..7cc9f92b52 100644
--- a/apps/plugins/lrcplayer.c
+++ b/apps/plugins/lrcplayer.c
@@ -1959,14 +1959,7 @@ static void save_changes(void)
1959 if (!current.changed_lrc) 1959 if (!current.changed_lrc)
1960 return; 1960 return;
1961 rb->splash(HZ/2, "Saving changes..."); 1961 rb->splash(HZ/2, "Saving changes...");
1962 if (current.type > NUM_TYPES) 1962 if (current.type == TXT || current.type > NUM_TYPES)
1963 {
1964 /* save changes to new .lrc8 file */
1965 rb->strcpy(new_file, current.lrc_file);
1966 p = rb->strrchr(new_file, '.');
1967 rb->strcpy(p, extentions[LRC8]);
1968 }
1969 else if (current.type == TXT)
1970 { 1963 {
1971 /* save changes to new .lrc file */ 1964 /* save changes to new .lrc file */
1972 rb->strcpy(new_file, current.lrc_file); 1965 rb->strcpy(new_file, current.lrc_file);
@@ -1994,7 +1987,10 @@ static void save_changes(void)
1994 } 1987 }
1995 current.offset = 0; 1988 current.offset = 0;
1996 if (current.type > NUM_TYPES) 1989 if (current.type > NUM_TYPES)
1990 {
1997 curr = -1; 1991 curr = -1;
1992 rb->write(fd, BOM, BOM_SIZE);
1993 }
1998 else 1994 else
1999 size = rb->filesize(fe); 1995 size = rb->filesize(fe);
2000 while (curr < size) 1996 while (curr < size)
@@ -2005,8 +2001,7 @@ static void save_changes(void)
2005 temp_lrc; temp_lrc = temp_lrc->next) 2001 temp_lrc; temp_lrc = temp_lrc->next)
2006 { 2002 {
2007 offset = temp_lrc->file_offset; 2003 offset = temp_lrc->file_offset;
2008 if (offset == -1 || 2004 if (offset < next && temp_lrc->old_time_start == -1)
2009 (offset < next && temp_lrc->old_time_start == -1))
2010 { 2005 {
2011 lrc_line = temp_lrc; 2006 lrc_line = temp_lrc;
2012 next = offset; 2007 next = offset;
@@ -2014,7 +2009,7 @@ static void save_changes(void)
2014 } 2009 }
2015 } 2010 }
2016 offset = current.offset_file_offset; 2011 offset = current.offset_file_offset;
2017 if (offset >= curr && offset < next) 2012 if (offset >= 0 && offset < next)
2018 { 2013 {
2019 lrc_line = NULL; 2014 lrc_line = NULL;
2020 next = offset; 2015 next = offset;
@@ -2073,16 +2068,11 @@ static void save_changes(void)
2073 2068
2074 if (success) 2069 if (success)
2075 { 2070 {
2076 if (current.type == TXT) 2071 if (current.type == TXT || current.type > NUM_TYPES)
2077 { 2072 {
2078 current.type = LRC; 2073 current.type = LRC;
2079 rb->strcpy(current.lrc_file, new_file); 2074 rb->strcpy(current.lrc_file, new_file);
2080 } 2075 }
2081 else if (current.type > NUM_TYPES)
2082 {
2083 current.type = LRC8;
2084 rb->strcpy(current.lrc_file, new_file);
2085 }
2086 else 2076 else
2087 { 2077 {
2088 rb->remove(current.lrc_file); 2078 rb->remove(current.lrc_file);
@@ -2915,14 +2905,15 @@ enum plugin_status plugin_start(const void* parameter)
2915 return PLUGIN_ERROR; 2905 return PLUGIN_ERROR;
2916 } 2906 }
2917 ext = rb->strrchr(current.lrc_file, '.'); 2907 ext = rb->strrchr(current.lrc_file, '.');
2918 for (current.type = 0; ext && current.type < NUM_TYPES; current.type++) 2908 if (!ext) ext = current.lrc_file;
2909 for (current.type = 0; current.type < NUM_TYPES; current.type++)
2919 { 2910 {
2920 if (!rb->strcmp(ext, extentions[current.type])) 2911 if (!rb->strcmp(ext, extentions[current.type]))
2921 break; 2912 break;
2922 } 2913 }
2923 if (!ext || current.type == NUM_TYPES) 2914 if (current.type == NUM_TYPES)
2924 { 2915 {
2925 rb->splashf(HZ, "%s is not supported", ext? ext: current.lrc_file); 2916 rb->splashf(HZ, "%s is not supported", ext);
2926 return PLUGIN_ERROR; 2917 return PLUGIN_ERROR;
2927 } 2918 }
2928 current.found_lrc = true; 2919 current.found_lrc = true;