Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
avoid potential segfault when fed nonsense
authordegomme <adegomme@users.noreply.github.com>
Tue, 2 Apr 2019 08:37:49 +0000 (10:37 +0200)
committerdegomme <adegomme@users.noreply.github.com>
Tue, 2 Apr 2019 08:37:49 +0000 (10:37 +0200)
src/smpi/bindings/smpi_pmpi.cpp

index 43cbdb8..6b831d5 100644 (file)
@@ -215,7 +215,7 @@ int PMPI_Error_class(int errorcode, int* errorclass) {
 }
 
 int PMPI_Error_string(int errorcode, char* string, int* resultlen){
 }
 
 int PMPI_Error_string(int errorcode, char* string, int* resultlen){
-  if (errorcode<0 || string ==nullptr){
+  if (errorcode<0 || errorcode>= MPI_MAX_ERROR_STRING || string ==nullptr){
     return MPI_ERR_ARG;
   } else {
     static const char *smpi_error_string[] = {
     return MPI_ERR_ARG;
   } else {
     static const char *smpi_error_string[] = {