浏览代码

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

Miklos Tirpak 16 年之前
父节点
当前提交
d1e2ffe61f
共有 1 个文件被更改,包括 9 次插入0 次删除
  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 *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)
 			|| (allocate_buffer(req_size))) {
 		/* enough space in current buffer or allocation successful */