Changeset: 5062e807b701 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5062e807b701
Modified Files:
gdk/gdk_storage.c
Branch: Aug2011
Log Message:
BATmultiprintf: use GDKmalloc instead of alloca
Avoid stack smashing, although it is unlikely to happen ever.
diffs (46 lines):
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -1182,11 +1182,23 @@
int printorder /* boolean: print the orderby column? */
)
{
- col_format_t *c = (col_format_t *) alloca((unsigned) (argc *
sizeof(col_format_t)));
- col_format_t **cp = (col_format_t **) alloca((unsigned) ((argc + 1) *
sizeof(void *)));
- ColFcn *value_fcn = (ColFcn *) alloca((unsigned) (argc *
sizeof(ColFcn)));
+ col_format_t *c = (col_format_t *) GDKmalloc((unsigned) (argc *
sizeof(col_format_t)));
+ col_format_t **cp = (col_format_t **) GDKmalloc((unsigned) ((argc + 1)
* sizeof(void *)));
+ ColFcn *value_fcn = (ColFcn *) GDKmalloc((unsigned) (argc *
sizeof(ColFcn)));
int ret = 0, j, total = 0;
+ if (c == NULL)
+ return -1;
+ if (cp == NULL) {
+ GDKfree(c);
+ return -1;
+ }
+ if (value_fcn == NULL) {
+ GDKfree(c);
+ GDKfree(cp);
+ return -1;
+ }
+
/*
* @-
* Init the column descriptor of the head column.
@@ -1251,11 +1263,14 @@
* @-
* Cleanup.
*/
- cleanup:
+cleanup:
for (j = 0; j <= argc; j++) {
if (c[j].buf)
GDKfree(c[j].buf);
}
+ GDKfree(c);
+ GDKfree(cp);
+ GDKfree(value_fcn);
return ret;
}
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list