summaryrefslogtreecommitdiffstats
path: root/sys/boot/common/module.c
diff options
context:
space:
mode:
authordcs <dcs@FreeBSD.org>1999-02-22 13:12:37 +0000
committerdcs <dcs@FreeBSD.org>1999-02-22 13:12:37 +0000
commit3b2e9c970d1b3c4670c145d0363db0fabc8ee122 (patch)
tree332b8d8aa02a493f27ddc9da58ee8b7fc486242d /sys/boot/common/module.c
parent62572be175c190ab32f7db9990d3169dd1883b83 (diff)
downloadFreeBSD-src-3b2e9c970d1b3c4670c145d0363db0fabc8ee122.zip
FreeBSD-src-3b2e9c970d1b3c4670c145d0363db0fabc8ee122.tar.gz
Fix assorted memory leak/buffer reuse problems.
Not restricted to, but including: PR: kern/9631 Submitted by: Bill Fenner <fenner@parc.xerox.com>
Diffstat (limited to 'sys/boot/common/module.c')
-rw-r--r--sys/boot/common/module.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/boot/common/module.c b/sys/boot/common/module.c
index 141a8ed..bacdf7a 100644
--- a/sys/boot/common/module.c
+++ b/sys/boot/common/module.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: module.c,v 1.6 1998/10/09 23:12:34 peter Exp $
+ * $Id: module.c,v 1.7 1999/01/11 06:41:31 msmith Exp $
*/
/*
@@ -256,6 +256,7 @@ mod_loadobj(char *type, char *name)
break;
if (got < 0) { /* error */
sprintf(command_errbuf, "error reading '%s': %s", name, strerror(errno));
+ free(name);
return(CMD_ERROR);
}
laddr += got;
@@ -263,7 +264,7 @@ mod_loadobj(char *type, char *name)
/* Looks OK so far; create & populate control structure */
mp = malloc(sizeof(struct loaded_module));
- mp->m_name = strdup(name);
+ mp->m_name = name;
mp->m_type = strdup(type);
mp->m_args = NULL;
mp->m_metadata = NULL;
@@ -442,9 +443,12 @@ mod_searchfile(char *name)
struct stat sb;
/* Don't look for nothing */
- if ((name == NULL) || (*name == 0))
+ if (name == NULL)
return(name);
+ if (*name == 0)
+ return(strdup(name));
+
/*
* See if there's a device on the front, or a directory name.
*/
@@ -452,7 +456,7 @@ mod_searchfile(char *name)
if ((cp != name) || (strchr(name, '/') != NULL)) {
/* Qualified, so just see if it exists */
if (stat(name, &sb) == 0)
- return(name);
+ return(strdup(name));
return(NULL);
}
OpenPOWER on IntegriCloud