@@ -745,13 +745,19 @@ static int scheme_getall(void *user_data, SablotHandle proc, const char *scheme,
745
745
xslt_call_function ("scheme get all" , XSLT_SCHEME (handle ).get_all ,
746
746
3 , argv , & retval );
747
747
748
+ if (!retval ) {
749
+ /* return failure */
750
+ return 1 ;
751
+ }
752
+
748
753
/* Save the return value in the buffer (copying it) */
749
754
* buffer = estrndup (Z_STRVAL_P (retval ), Z_STRLEN_P (retval ));
750
755
* byte_count = Z_STRLEN_P (retval );
751
756
752
757
/* Free return value */
753
758
zval_ptr_dtor (& retval );
754
-
759
+
760
+ /* return success */
755
761
return 0 ;
756
762
}
757
763
/* }}} */
@@ -823,12 +829,22 @@ static int scheme_open(void *user_data, SablotHandle proc, const char *scheme,
823
829
xslt_call_function ("scheme open" , XSLT_SCHEME (handle ).open ,
824
830
3 , argv , & retval );
825
831
832
+ if (!retval ) {
833
+ /* return failure */
834
+ return 1 ;
835
+ }
836
+
826
837
/* Return value is a resource pointer to an open file */
827
838
* fd = Z_LVAL_P (retval );
828
-
839
+
829
840
/* Free it all up */
830
841
zval_ptr_dtor (& retval );
831
842
843
+ if (!* fd ) {
844
+ /* return failure - unsupported scheme */
845
+ return SH_ERR_UNSUPPORTED_SCHEME ;
846
+ }
847
+
832
848
/* return success */
833
849
return 0 ;
834
850
}
@@ -867,6 +883,11 @@ static int scheme_get(void *user_data, SablotHandle proc, int fd, char *buffer,
867
883
xslt_call_function ("scheme get" , XSLT_SCHEME (handle ).get ,
868
884
3 , argv , & retval );
869
885
886
+ if (!retval ) {
887
+ /* return failure */
888
+ return 1 ;
889
+ }
890
+
870
891
/* Returns the number of bytes read */
871
892
* byte_count = Z_LVAL_P (retval );
872
893
@@ -911,6 +932,11 @@ static int scheme_put(void *user_data, SablotHandle proc, int fd, const char *b
911
932
xslt_call_function ("scheme put" , XSLT_SCHEME (handle ).put ,
912
933
3 , argv , & retval );
913
934
935
+ if (!retval ) {
936
+ /* return failure */
937
+ return 1 ;
938
+ }
939
+
914
940
/* The return value is the number of bytes written */
915
941
* byte_count = Z_LVAL_P (retval );
916
942
@@ -952,6 +978,11 @@ static int scheme_close(void *user_data, SablotHandle proc, int fd)
952
978
xslt_call_function ("scheme close" , XSLT_SCHEME (handle ).close ,
953
979
2 , argv , & retval );
954
980
981
+ if (!retval ) {
982
+ /* return failure */
983
+ return 1 ;
984
+ }
985
+
955
986
/* Free everything up */
956
987
zval_ptr_dtor (& retval );
957
988
@@ -986,7 +1017,8 @@ static SAX_RETURN sax_startdoc(void *ctx, SablotHandle processor)
986
1017
1 , argv , & retval );
987
1018
988
1019
/* Cleanup */
989
- zval_ptr_dtor (& retval );
1020
+ if (retval )
1021
+ zval_ptr_dtor (& retval );
990
1022
}
991
1023
/* }}} */
992
1024
@@ -1034,7 +1066,8 @@ static SAX_RETURN sax_startelement(void *ctx, SablotHandle processor,
1034
1066
3 , argv , & retval );
1035
1067
1036
1068
/* Cleanup */
1037
- zval_ptr_dtor (& retval );
1069
+ if (retval )
1070
+ zval_ptr_dtor (& retval );
1038
1071
}
1039
1072
/* }}} */
1040
1073
@@ -1068,7 +1101,8 @@ static SAX_RETURN sax_endelement(void *ctx, SablotHandle processor, const char *
1068
1101
2 , argv , & retval );
1069
1102
1070
1103
/* Cleanup */
1071
- zval_ptr_dtor (& retval );
1104
+ if (retval )
1105
+ zval_ptr_dtor (& retval );
1072
1106
}
1073
1107
/* }}} */
1074
1108
@@ -1107,7 +1141,8 @@ static SAX_RETURN sax_startnamespace(void *ctx, SablotHandle processor,
1107
1141
3 , argv , & retval );
1108
1142
1109
1143
/* Cleanup */
1110
- zval_ptr_dtor (& retval );
1144
+ if (retval )
1145
+ zval_ptr_dtor (& retval );
1111
1146
}
1112
1147
/* }}} */
1113
1148
@@ -1141,7 +1176,8 @@ static SAX_RETURN sax_endnamespace(void *ctx, SablotHandle processor, const char
1141
1176
2 , argv , & retval );
1142
1177
1143
1178
/* Cleanup */
1144
- zval_ptr_dtor (& retval );
1179
+ if (retval )
1180
+ zval_ptr_dtor (& retval );
1145
1181
}
1146
1182
/* }}} */
1147
1183
@@ -1175,7 +1211,8 @@ static SAX_RETURN sax_comment(void *ctx, SablotHandle processor, const char *con
1175
1211
2 , argv , & retval );
1176
1212
1177
1213
/* Cleanup */
1178
- zval_ptr_dtor (& retval );
1214
+ if (retval )
1215
+ zval_ptr_dtor (& retval );
1179
1216
}
1180
1217
/* }}} */
1181
1218
@@ -1214,7 +1251,8 @@ static SAX_RETURN sax_pi(void *ctx, SablotHandle processor,
1214
1251
3 , argv , & retval );
1215
1252
1216
1253
/* Cleanup */
1217
- zval_ptr_dtor (& retval );
1254
+ if (retval )
1255
+ zval_ptr_dtor (& retval );
1218
1256
}
1219
1257
/* }}} */
1220
1258
@@ -1250,7 +1288,8 @@ static SAX_RETURN sax_characters(void *ctx, SablotHandle processor,
1250
1288
2 , argv , & retval );
1251
1289
1252
1290
/* Cleanup */
1253
- zval_ptr_dtor (& retval );
1291
+ if (retval )
1292
+ zval_ptr_dtor (& retval );
1254
1293
}
1255
1294
/* }}} */
1256
1295
@@ -1281,7 +1320,8 @@ static SAX_RETURN sax_enddoc(void *ctx, SablotHandle processor)
1281
1320
1 , argv , & retval );
1282
1321
1283
1322
/* Cleanup */
1284
- zval_ptr_dtor (& retval );
1323
+ if (retval )
1324
+ zval_ptr_dtor (& retval );
1285
1325
}
1286
1326
/* }}} */
1287
1327
@@ -1499,7 +1539,8 @@ static MH_ERROR error_print(void *user_data, SablotHandle proc, MH_ERROR code, M
1499
1539
4 , argv , & retval );
1500
1540
1501
1541
/* Free up */
1502
- zval_ptr_dtor (& retval );
1542
+ if (retval )
1543
+ zval_ptr_dtor (& retval );
1503
1544
}
1504
1545
else {
1505
1546
char * errmsg = NULL ; /* Error message */
0 commit comments