diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2016-12-05 20:30:28 +0000 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2016-12-05 20:30:48 +0000 |
commit | 2fe884be6532bb86ed8e2f2aa3d278ebaee6a406 (patch) | |
tree | 0e633329eb3d218eb75bcdd976b94791a0c92f63 | |
parent | 71afaacc80c6d94e1406249c61c338a4131d24a7 (diff) | |
download | netsurf-2fe884be6532bb86ed8e2f2aa3d278ebaee6a406.tar.gz netsurf-2fe884be6532bb86ed8e2f2aa3d278ebaee6a406.tar.bz2 |
Fix memory leak searching for resources
-rw-r--r-- | frontends/amiga/gui.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c index 3e68c904d..7265f8f82 100644 --- a/frontends/amiga/gui.c +++ b/frontends/amiga/gui.c @@ -350,18 +350,19 @@ static bool ami_gui_check_resource(char *fullpath, const char *file) BPTR lock = 0; size_t fullpath_len = 1024; - ami_gui_map_filename(&remapped, fullpath, file, "Resource.map"); - netsurf_mkpath(&fullpath, &fullpath_len, 2, fullpath, remapped); + if(ami_gui_map_filename(&remapped, fullpath, file, "Resource.map") == true) { + netsurf_mkpath(&fullpath, &fullpath_len, 2, fullpath, remapped); - lock = Lock(fullpath, ACCESS_READ); - if(lock) - { - UnLock(lock); - found = true; - } + lock = Lock(fullpath, ACCESS_READ); + if(lock) + { + UnLock(lock); + found = true; + } - if(found) LOG("Found %s", fullpath); - free(remapped); + if(found) LOG("Found %s", fullpath); + free(remapped); + } return found; } @@ -371,7 +372,7 @@ bool ami_locate_resource(char *fullpath, const char *file) struct Locale *locale; int i; bool found = false; - char *remapped; + char *remapped = NULL; size_t fullpath_len = 1024; /* Check NetSurf user data area first */ @@ -397,11 +398,12 @@ bool ami_locate_resource(char *fullpath, const char *file) strcpy(fullpath, "PROGDIR:Resources/"); if(locale->loc_PrefLanguages[i]) { - ami_gui_map_filename(&remapped, "PROGDIR:Resources", - locale->loc_PrefLanguages[i], "LangNames"); - netsurf_mkpath(&fullpath, &fullpath_len, 2, fullpath, remapped); - - found = ami_gui_check_resource(fullpath, file); + if(ami_gui_map_filename(&remapped, "PROGDIR:Resources", + locale->loc_PrefLanguages[i], "LangNames") == true) { + netsurf_mkpath(&fullpath, &fullpath_len, 2, fullpath, remapped); + found = ami_gui_check_resource(fullpath, file); + free(remapped); + } } else { continue; } |