소스 검색

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 */