From 5cdd920d1267a7548ab492864c4a20a20c3d93ff Mon Sep 17 00:00:00 2001 From: Teruaki Kawashima Date: Sun, 6 Dec 2009 13:52:28 +0000 Subject: Correct checking return value of open in plugins. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23874 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/search.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'apps/plugins/search.c') diff --git a/apps/plugins/search.c b/apps/plugins/search.c index e9732d2..d732c02 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; } -- cgit v1.1