Commit af080143 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Fix a few potential memory leaks

Some of the long filenames handling added in DOSFS-0_79 (DOSFSops.c revision 4.10) introduced extra points to return in the face of error, but didn't free memory allocated earlier in the function.
Add missing free()'s.
From a tip off from Dominic Plunkett in http://www.riscosopen.org/forum/forums/4/topics/3990#posts-51013

Version 1.09. Tagged as 'DOSFS-1_09'
parent dac80f3c
/* (1.08)
/* (1.09)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.08
#define Module_MajorVersion_CMHG 1.09
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 02 Nov 2014
#define Module_Date_CMHG 18 Mar 2016
#define Module_MajorVersion "1.08"
#define Module_Version 108
#define Module_MajorVersion "1.09"
#define Module_Version 109
#define Module_MinorVersion ""
#define Module_Date "02 Nov 2014"
#define Module_Date "18 Mar 2016"
#define Module_ApplicationDate "02-Nov-14"
#define Module_ApplicationDate "18-Mar-16"
#define Module_ComponentName "DOSFS"
#define Module_ComponentPath "castle/RiscOS/Sources/FileSys/ImageFS/DOSFS"
#define Module_FullVersion "1.08"
#define Module_HelpVersion "1.08 (02 Nov 2014)"
#define Module_LibraryVersionInfo "1:8"
#define Module_FullVersion "1.09"
#define Module_HelpVersion "1.09 (18 Mar 2016)"
#define Module_LibraryVersionInfo "1:9"
......@@ -555,6 +555,8 @@ int DOSFS_create_dir(char *fname, word ld, word ex, word size, DOSdisc *ihand)
dprintf(("","DOSFS_create_dir: numreq = %d\n",numreq));
if (get_dir_entry_array(lfn, ihand, numreq, &cdir, &pdir,NULL) < 0)
{
free(DOSname);
free(memaddr);
return -1;
}
......@@ -592,6 +594,8 @@ int DOSFS_create_dir(char *fname, word ld, word ex, word size, DOSdisc *ihand)
longfileholder = (char *)malloc(strlen(leafname) + 1);
if (longfileholder == NULL)
{
free(DOSname);
free(memaddr);
return_errorT(int, err_heapexhausted, tok_heapexhausted, 0, 0);
}
strcpy(longfileholder, leafname);
......
......@@ -155,6 +155,7 @@ int DOSFS_rename(char *oldname,char *newname,DOSdisc *ihand)
if (get_dir_entry_array(lfn, ihand, numreq, &ndir, &dummy, &found) < 0)
{
free(DOSname) ;
return -1;
}
......@@ -188,6 +189,7 @@ int DOSFS_rename(char *oldname,char *newname,DOSdisc *ihand)
longfileholder = malloc(strlen(leafname) + 1);
if (longfileholder == NULL)
{
free(DOSname) ;
return_errorT(int, err_heapexhausted, tok_heapexhausted, 0, 0);
}
strcpy(longfileholder, leafname);
......
......@@ -307,7 +307,10 @@ char *MSDOStoSTRING(word MSDOStime,word MSDOSdate)
reglist.r[1] = (word)buffer ;
reglist.r[2] = (MaxString - 1) ;
if ((rerror = _kernel_swi(OS_ConvertStandardDateAndTime,&reglist,&reglist)) != NULL)
{
free(buffer) ;
return(NULL) ;
}
return(buffer) ;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment