Revision: 41327
http://brlcad.svn.sourceforge.net/brlcad/?rev=41327&view=rev
Author: brlcad
Date: 2010-11-11 04:02:24 +0000 (Thu, 11 Nov 2010)
Log Message:
-----------
random crash report showed a crash inside free() from
bu_tcl_get_value_by_keyword(), so add additional protections. Call Tcl_Free()
instead of free() directly since that's what the Tcl doc's say should be called
after Tcl_SplitList(). also init listv to NULL for the case where listc is 0.
Modified Paths:
--------------
brlcad/trunk/src/libbu/tcl.c
Modified: brlcad/trunk/src/libbu/tcl.c
===================================================================
--- brlcad/trunk/src/libbu/tcl.c 2010-11-11 02:53:45 UTC (rev 41326)
+++ brlcad/trunk/src/libbu/tcl.c 2010-11-11 04:02:24 UTC (rev 41327)
@@ -278,11 +278,11 @@
int argc,
const char **argv)
{
- int listc;
- const char **listv;
- const char *iwant;
+ int i = 0;
+ int listc = 0;
+ const char *iwant = (const char *)NULL;
+ const char **listv = (const char **)NULL;
const char **tofree = (const char **)NULL;
- int i;
/* quell usage warning */
clientData = clientData;
@@ -302,10 +302,7 @@
if (argc == 3) {
if (Tcl_SplitList(interp, argv[2], &listc, (const char ***)&listv) !=
TCL_OK) {
- Tcl_AppendResult(interp,
- "bu_get_value_by_keyword: iwant='", iwant,
- "', unable to split '",
- argv[2], "'\n", (char *)NULL);
+ Tcl_AppendResult(interp, "bu_get_value_by_keyword: iwant='", iwant,
"', unable to split '", argv[2], "'\n", (char *)NULL);
return TCL_ERROR;
}
tofree = listv;
@@ -318,10 +315,9 @@
if ((listc & 1) != 0) {
char buf[TINYBUFSIZ];
snprintf(buf, TINYBUFSIZ, "%d", listc);
- Tcl_AppendResult(interp,
- "bu_get_value_by_keyword: odd # of items in list (",
buf, ").\n",
- (char *)NULL);
- if (tofree) free((char *)tofree); /* not bu_free() */
+ Tcl_AppendResult(interp, "bu_get_value_by_keyword: odd # of items in
list (", buf, ").\n", (char *)NULL);
+ if (tofree)
+ Tcl_Free(tofree); /* not bu_free() */
return TCL_ERROR;
}
@@ -335,21 +331,21 @@
bu_vls_strcat(&str, &listv[i+1][1]);
/* Trim trailing } */
bu_vls_trunc(&str, -1);
- Tcl_AppendResult(interp,
- bu_vls_addr(&str), (char *)NULL);
+ Tcl_AppendResult(interp, bu_vls_addr(&str), (char *)NULL);
bu_vls_free(&str);
} else {
Tcl_AppendResult(interp, listv[i+1], (char *)NULL);
}
- if (tofree) free((char *)tofree); /* not bu_free() */
+ if (tofree)
+ Tcl_Free(tofree); /* not bu_free() */
return TCL_OK;
}
}
/* Not found */
- Tcl_AppendResult(interp, "bu_get_value_by_keyword: keyword '",
- iwant, "' not found in list\n", (char *)NULL);
- if (tofree) free((char *)tofree); /* not bu_free() */
+ Tcl_AppendResult(interp, "bu_get_value_by_keyword: keyword '", iwant, "'
not found in list\n", (char *)NULL);
+ if (tofree)
+ Tcl_Free(tofree); /* not bu_free() */
return TCL_ERROR;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits