diff options
author | Teruaki Kawashima <teru@rockbox.org> | 2009-12-06 13:52:28 +0000 |
---|---|---|
committer | Teruaki Kawashima <teru@rockbox.org> | 2009-12-06 13:52:28 +0000 |
commit | 5cdd920d1267a7548ab492864c4a20a20c3d93ff (patch) | |
tree | 518ddb3cbbf4eabcb8ca0941e386a285c56b53bb /apps/plugins/search.c | |
parent | e760a5abbf951fd22e1dd8eb116e344ad3d76a61 (diff) | |
download | rockbox-5cdd920d1267a7548ab492864c4a20a20c3d93ff.tar.gz rockbox-5cdd920d1267a7548ab492864c4a20a20c3d93ff.zip |
Correct checking return value of open in plugins.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23874 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/search.c')
-rw-r--r-- | apps/plugins/search.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/apps/plugins/search.c b/apps/plugins/search.c index e9732d219b..d732c0282b 100644 --- a/apps/plugins/search.c +++ b/apps/plugins/search.c @@ -121,7 +121,7 @@ static bool search_init(const char* file){ clear_display(); rb->splash(0, "Searching..."); fd = rb->open(file, O_RDONLY); - if (fd==-1) + if (fd < 0) return false; fdw = rb->creat(resultfile); @@ -132,6 +132,7 @@ static bool search_init(const char* file){ #else rb->splash(HZ, "File creation failed"); #endif + rb->close(fd); return false; } @@ -153,8 +154,9 @@ enum plugin_status plugin_start(const void* parameter) DEBUGF("%s - %s\n", (char *)parameter, &filename[rb->strlen(filename)-4]); /* Check the extension. We only allow .m3u files. */ - if(rb->strcasecmp(&filename[rb->strlen(filename)-4], ".m3u") && - rb->strcasecmp(&filename[rb->strlen(filename)-5], ".m3u8")) { + if (!(p = rb->strrchr(filename, '.')) || + (rb->strcasecmp(p, ".m3u") && rb->strcasecmp(p, ".m3u8"))) + { rb->splash(HZ, "Not a .m3u or .m3u8 file"); return PLUGIN_ERROR; } |