#! /bin/sh /usr/share/dpatch/dpatch-run
## 310-rlm_exec-nullchecks.dpatch by  <joe@nameserver3.ttec.com>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad freeradius-2.0.0~/src/modules/rlm_exec/rlm_exec.c freeradius-2.0.0/src/modules/rlm_exec/rlm_exec.c
--- freeradius-2.0.0~/src/modules/rlm_exec/rlm_exec.c	2005-12-22 09:40:30.000000000 -0500
+++ freeradius-2.0.0/src/modules/rlm_exec/rlm_exec.c	2006-01-24 18:35:58.000000000 -0500
@@ -281,6 +281,13 @@
 	VALUE_PAIR *answer;
 	rlm_exec_t *inst = (rlm_exec_t *) instance;
 
+	if (!inst || !request) {
+		radlof(L_ERR, "%s: %s() line: %d , a very bad thing happened",
+				__FILE__, __func__, __LINE__);
+		return RLM_MODULE_NOOP;
+	}
+		
+
 	/*
 	 *	We need a program to execute.
 	 */
@@ -294,8 +301,10 @@
 	 *	See if we're supposed to execute it now.
 	 */
 	if (!((inst->packet_code == 0) ||
-	      (request->packet->code == inst->packet_code) ||
-	      (request->reply->code == inst->packet_code) ||
+	      (request->packet && 
+	       request->packet->code == inst->packet_code) ||
+	      (request->reply && 
+	       request->reply->code == inst->packet_code) ||
 	      (request->proxy &&
 	       (request->proxy->code == inst->packet_code)) ||
 	      (request->proxy_reply &&
