@@ -780,21 +780,49 @@ static apr_status_t msre_parse_actions(msre_engine *engine, msre_actionset *acti
780780msre_action * action ;
781781int i ;
782782
783- if (text == NULL )return -1 ;
783+
784+ if (error_msg == NULL ) {
785+ return -1 ;
786+ }
787+ * error_msg = NULL ;
788+
789+
790+ if (text == NULL ) {
791+ * error_msg = apr_psprintf (engine -> mp ,"Internal error: " \
792+ "msre_parse_actions, variable text is NULL" );
793+ return -1 ;
794+ }
784795
785796/* Extract name & value pairs first */
786797vartable = apr_table_make (engine -> mp ,10 );
787- if (vartable == NULL )return -1 ;
798+ if (vartable == NULL ) {
799+ * error_msg = apr_psprintf (engine -> mp ,"Internal error: " \
800+ "msre_parse_actions, failed to create vartable" );
801+
802+ return -1 ;
803+ }
788804rc = msre_parse_generic (engine -> mp ,text ,vartable ,error_msg );
789- if (rc < 0 )return rc ;
805+ if (rc < 0 ) {
806+ if (* error_msg == NULL )
807+ * error_msg = apr_psprintf (engine -> mp ,"Internal error: " \
808+ "msre_parse_actions, msre_parse_generic failed. Return " \
809+ "code: %d" ,rc );
810+
811+ return rc ;
812+ }
790813
791814/* Loop through the table and create actions */
792815tarr = apr_table_elts (vartable );
793816telts = (const apr_table_entry_t * )tarr -> elts ;
794817for (i = 0 ;i < tarr -> nelts ;i ++ ) {
795818/* Create action. */
796819action = msre_create_action (engine ,telts [i ].key ,telts [i ].val ,error_msg );
797- if (action == NULL )return -1 ;
820+ if (action == NULL ) {
821+ if (* error_msg == NULL )
822+ * error_msg = apr_psprintf (engine -> mp ,"Internal error: " \
823+ "msre_parse_actions, msre_create_action failed." );
824+ return -1 ;
825+ }
798826
799827/* Initialise action (option). */
800828if (action -> metadata -> init != NULL ) {
@@ -932,12 +960,23 @@ static msre_var *msre_create_var(msre_ruleset *ruleset, const char *name, const
932960msre_action * msre_create_action (msre_engine * engine ,const char * name ,const char * param ,
933961char * * error_msg )
934962{
935- msre_action * action = apr_pcalloc (engine -> mp ,sizeof (msre_action ));
936- if (action == NULL )return NULL ;
963+ msre_action * action = NULL ;
937964
938- if (error_msg == NULL )return NULL ;
965+ if (error_msg == NULL ) {
966+ return NULL ;
967+ }
939968* error_msg = NULL ;
940969
970+
971+ action = apr_pcalloc (engine -> mp ,sizeof (msre_action ));
972+
973+ if (action == NULL ) {
974+ * error_msg = apr_psprintf (engine -> mp ,"Internal error: " \
975+ "msre_create_action, not able to allocate action" );
976+
977+ return NULL ;
978+ }
979+
941980/* Resolve action */
942981action -> metadata = msre_resolve_action (engine ,name );
943982if (action -> metadata == NULL ) {
@@ -1128,12 +1167,29 @@ int msre_parse_generic(apr_pool_t *mp, const char *text, apr_table_t *vartable,
11281167msre_actionset * msre_actionset_create (msre_engine * engine ,const char * text ,
11291168char * * error_msg )
11301169{
1131- msre_actionset * actionset = (msre_actionset * )apr_pcalloc (engine -> mp ,
1170+ msre_actionset * actionset = NULL ;
1171+
1172+ if (error_msg == NULL ) {
1173+ return NULL ;
1174+ }
1175+
1176+ * error_msg = NULL ;
1177+
1178+ actionset = (msre_actionset * )apr_pcalloc (engine -> mp ,
11321179sizeof (msre_actionset ));
1133- if (actionset == NULL )return NULL ;
1180+
1181+ if (actionset == NULL ) {
1182+ * error_msg = apr_psprintf (engine -> mp ,"Internal error: " \
1183+ "msre_actionset_create, not able to allocate msre_actionset" );
1184+ return NULL ;
1185+ }
11341186
11351187actionset -> actions = apr_table_make (engine -> mp ,25 );
1136- if (actionset -> actions == NULL )return NULL ;
1188+ if (actionset -> actions == NULL ) {
1189+ * error_msg = apr_psprintf (engine -> mp ,"Internal error: " \
1190+ "msre_actionset_create, not able to create actions table" );
1191+ return NULL ;
1192+ }
11371193
11381194/* Metadata */
11391195actionset -> id = NOT_SET_P ;
@@ -1169,7 +1225,12 @@ msre_actionset *msre_actionset_create(msre_engine *engine, const char *text,
11691225
11701226/* Parse the list of actions, if it's present */
11711227if (text != NULL ) {
1172- if (msre_parse_actions (engine ,actionset ,text ,error_msg )< 0 ) {
1228+ int ret = msre_parse_actions (engine ,actionset ,text ,error_msg );
1229+ if (ret < 0 ) {
1230+ if (* error_msg == NULL )
1231+ * error_msg = apr_psprintf (engine -> mp ,"Internal error: " \
1232+ "msre_actionset_create, msre_parse_actions failed " \
1233+ "without further information. Return code: %d" ,ret );
11731234return NULL ;
11741235 }
11751236 }