Browse code

Safety check added to verify whether the static buffers have been initialized.

Miklos Tirpak authored on 07/04/2009 09:07:48
Showing 1 changed files
... ...
@@ -105,6 +105,15 @@ static int allocate_buffer(int req_size) {
105 105
 
106 106
 char* get_static_buffer(int req_size) {
107 107
 	char *p = NULL;
108
+
109
+#ifdef EXTRA_DEBUG
110
+	if ((active_buffer < 0) || (active_buffer > MAX_BUFFERS-1)) {
111
+		LOG(L_CRIT, "BUG: buffers have not been initialized yet. "
112
+			"Call reset_static_buffer() before executing "
113
+			"a route block.\n");
114
+		abort();
115
+	}
116
+#endif
108 117
 	if ((buffer[active_buffer].size >= buffer[active_buffer].offset + req_size)
109 118
 			|| (allocate_buffer(req_size))) {
110 119
 		/* enough space in current buffer or allocation successful */