PERFORCE change 229863 for review
Jonathan Anderson
jonathan at FreeBSD.org
Tue Jun 18 09:03:23 UTC 2013
http://p4web.freebsd.org/@@229863?ac=10
Change 229863 by jonathan at jonathan-on-zenith on 2013/06/18 09:02:57
Ensure we don't create too many cloines.
Affected files ...
.. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_update.c#5 edit
Differences ...
==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_update.c#5 (text+ko) ====
@@ -89,6 +89,8 @@
print_class(class);
+ int error = TESLA_SUCCESS;
+
// Did we match any instances?
bool matched_something = false;
@@ -97,13 +99,15 @@
// Make space for cloning existing instances.
size_t cloned = 0;
+ const size_t max_clones = class->tc_free;
struct clone_info {
tesla_instance *old;
const tesla_transition *transition;
- } clones[class->tc_free];
+ } clones[max_clones];
// Iterate over existing instances, figure out what to do with each.
for (uint32_t i = 0; i < class->tc_limit; i++) {
+ assert(class->tc_instances != NULL);
tesla_instance *inst = class->tc_instances + i;
const tesla_transition *trigger = NULL;
@@ -129,6 +133,11 @@
break;
case FORK: {
+ if (cloned >= max_clones) {
+ error = TESLA_ERROR_ENOMEM;
+ goto cleanup;
+ }
+
struct clone_info *clone = clones + cloned++;
clone->old = inst;
clone->transition = trigger;
@@ -190,9 +199,9 @@
print_class(class);
PRINT("\n====\n\n");
+cleanup:
tesla_class_put(class);
-
- return (TESLA_SUCCESS);
+ return error;
}
enum tesla_action_t
More information about the p4-projects
mailing list