summaryrefslogtreecommitdiffstats
path: root/apps/talk.c
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-05-02 16:34:18 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-05-02 16:34:18 +0100
commitdadfbfc6a5a5705f3080f14b98941c3fd8c82368 (patch)
tree89f525315b818a17e5b235f02469aa1ec34c5792 /apps/talk.c
parente5e457b526f9fd18ae6c36c4afa12e3afd7f80ef (diff)
downloadrockbox-dadfbfc6a5a5705f3080f14b98941c3fd8c82368.tar.gz
rockbox-dadfbfc6a5a5705f3080f14b98941c3fd8c82368.zip
apps: fix close of negative fd in talk.c
Bug reported by UBSan. Change-Id: I02276521510acac8696499895fec15993c55aaf6
Diffstat (limited to 'apps/talk.c')
-rw-r--r--apps/talk.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/apps/talk.c b/apps/talk.c
index e440dd98b5..1be2a041c2 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -552,8 +552,8 @@ alloc_err:
}
static inline int load_voicefile_failure(int fd)
{
- /*if (fd >= 0) probably redundant */
- close(fd);
+ if (fd >= 0)
+ close(fd);
return -1;
}
/* load the voice file into the mp3 buffer */
@@ -829,7 +829,7 @@ void talk_init(void)
* and so we can re-use it if it's already allocated in any event */
filehandle = open_voicefile();
- if (filehandle > -1)
+ if (filehandle >= 0)
{
if (!load_voicefile_index(filehandle))
{
@@ -880,7 +880,8 @@ void talk_init(void)
voice_thread_init();
out:
- close(filehandle); /* close again, this was just to detect presence */
+ if (filehandle >= 0)
+ close(filehandle); /* close again, this was just to detect presence */
}
/* somebody else claims the mp3 buffer, e.g. for regular play/record */