diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-09-06 16:46:54 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-09-06 16:46:54 +0000 |
commit | 0f40754afb0b1f9681e5cec1354bb64af0bdf020 (patch) | |
tree | 8c7d532fa4fe2d506ab3b8dcc8bad4df90a7d4b0 /sys/arch | |
parent | d6153a295852046b08ff7d9ac62c8510cfe12398 (diff) |
seperate a variable into two, so that the size of a free() is remembered.
ok semarie
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/macppc/macppc/mainbus.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sys/arch/macppc/macppc/mainbus.c b/sys/arch/macppc/macppc/mainbus.c index 20635df9c00..13c6bdc5dca 100644 --- a/sys/arch/macppc/macppc/mainbus.c +++ b/sys/arch/macppc/macppc/mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mainbus.c,v 1.24 2015/05/06 02:36:01 jsg Exp $ */ +/* $OpenBSD: mainbus.c,v 1.25 2015/09/06 16:46:53 deraadt Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -69,15 +69,15 @@ mbattach(struct device *parent, struct device *self, void *aux) struct confargs nca; char name[64], *t = NULL; int reg[4], cpucnt; - int node, len, slen; + int node, len, tlen; node = OF_peer(0); len = OF_getprop(node, "model", name, sizeof(name)); if (len > 1) { name[len] = '\0'; - slen = strlen(name)+1; - if ((t = malloc(slen, M_DEVBUF, M_NOWAIT)) != NULL) - strlcpy(t, name, slen); + tlen = strlen(name)+1; + if ((t = malloc(tlen, M_DEVBUF, M_NOWAIT)) != NULL) + strlcpy(t, name, tlen); } @@ -86,11 +86,13 @@ mbattach(struct device *parent, struct device *self, void *aux) name[len] = '\0'; /* Old World Macintosh */ if ((strncmp(name, "AAPL", 4)) == 0) { + size_t plen; + hw_vendor = "Apple Computer, Inc."; - slen = strlen(t) + strlen(name) - 3; - if ((hw_prod = malloc(slen, M_DEVBUF, M_NOWAIT)) != NULL) { - snprintf(hw_prod, slen, "%s %s", t, name + 5); - free(t, M_DEVBUF, 0); + plen = strlen(t) + strlen(name) - 3; + if ((hw_prod = malloc(plen, M_DEVBUF, M_NOWAIT)) != NULL) { + snprintf(hw_prod, plen, "%s %s", t, name + 5); + free(t, M_DEVBUF, tlen); } } else { /* New World Macintosh or Unknown */ |