Browse Source

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

Miklos Tirpak 16 years ago
parent
commit
d1e2ffe61f
1 changed files with 9 additions and 0 deletions
  1. 9 0
      select_buf.c

+ 9 - 0
select_buf.c

@@ -105,6 +105,15 @@ static int allocate_buffer(int req_size) {
 
 
 char* get_static_buffer(int req_size) {
 char* get_static_buffer(int req_size) {
 	char *p = NULL;
 	char *p = NULL;
+
+#ifdef EXTRA_DEBUG
+	if ((active_buffer < 0) || (active_buffer > MAX_BUFFERS-1)) {
+		LOG(L_CRIT, "BUG: buffers have not been initialized yet. "
+			"Call reset_static_buffer() before executing "
+			"a route block.\n");
+		abort();
+	}
+#endif
 	if ((buffer[active_buffer].size >= buffer[active_buffer].offset + req_size)
 	if ((buffer[active_buffer].size >= buffer[active_buffer].offset + req_size)
 			|| (allocate_buffer(req_size))) {
 			|| (allocate_buffer(req_size))) {
 		/* enough space in current buffer or allocation successful */
 		/* enough space in current buffer or allocation successful */