summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2021-08-13 06:32:44 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2021-08-13 06:32:44 -0400
commit2df306923a2b09aa6e46a3e24e9b0335c8016a1d (patch)
treebf44f71ffb5b21271c9294b36d8f0cd0c8cc59f2
parent6de6e1459de28bef919b869ee757474c615cb787 (diff)
downloadrockbox-2df306923a2b09aa6e46a3e24e9b0335c8016a1d.tar.gz
rockbox-2df306923a2b09aa6e46a3e24e9b0335c8016a1d.zip
file_internal.c guard file_cache_reset() from null pointer
I feel this is probably unlikely to be called with a NULL pointer for cachep but being that we are already doing the check why not guard file_cache_reset as well Change-Id: I1a13767ef28a4129ae3513f7aa999fb6c1d6fad8
-rw-r--r--firmware/common/file_internal.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/firmware/common/file_internal.c b/firmware/common/file_internal.c
index 5f35e35abc..b92c4ea115 100644
--- a/firmware/common/file_internal.c
+++ b/firmware/common/file_internal.c
@@ -75,13 +75,15 @@ void file_cache_alloc(struct filestr_cache *cachep)
75/* free resources attached to the cache */ 75/* free resources attached to the cache */
76void file_cache_free(struct filestr_cache *cachep) 76void file_cache_free(struct filestr_cache *cachep)
77{ 77{
78 if (cachep && cachep->buffer) 78 if (cachep)
79 { 79 {
80 dc_release_buffer(cachep->buffer); 80 if(cachep->buffer)
81 cachep->buffer = NULL; 81 {
82 dc_release_buffer(cachep->buffer);
83 cachep->buffer = NULL;
84 }
85 file_cache_reset(cachep);
82 } 86 }
83
84 file_cache_reset(cachep);
85} 87}
86 88
87 89