diff --git a/optimizer/extlib/nsga2/nsga2.c b/optimizer/extlib/nsga2/nsga2.c
index 7fe8b8dad5e661c927ff16ee9d6a7eb1fe5880ec..6a8d568a463fdc4f79337377312d49b5fb8240e3 100644
--- a/optimizer/extlib/nsga2/nsga2.c
+++ b/optimizer/extlib/nsga2/nsga2.c
@@ -50,7 +50,7 @@ int main(int argc, char* argv[])
 
      /* other variables */
      int state = -1;
-     char statefile[FILE_NAME_LENGTH];
+     char *statefile;
      int result;
      
      /* reading command line parameters */
@@ -61,7 +61,7 @@ int main(int argc, char* argv[])
      sscanf(argv[3], "%lf", &poll);
 
      /* generate name of statefile */
-     sprintf(statefile, "%ssta", filenamebase);
+     asprintf(&statefile, "%ssta", filenamebase);
 
      /* main loop */
      while (state != 6) /* stop state for selector */
diff --git a/optimizer/extlib/nsga2/nsga2_io.c b/optimizer/extlib/nsga2/nsga2_io.c
index 88bb499418e15f33cef2f5b0368c8824d517356b..497b3e5377631c98b28fc261f7e126a401ed8787 100644
--- a/optimizer/extlib/nsga2/nsga2_io.c
+++ b/optimizer/extlib/nsga2/nsga2_io.c
@@ -94,7 +94,7 @@ void write_pop(char* filename, pop* pp, int size)
      int i;
      FILE *fp;
 
-     assert(0 <= size <= pp->size);
+     assert(0 <= size || size <= pp->size);
 
      fp = fopen(filename, "w");
      assert(fp != NULL);
@@ -129,4 +129,4 @@ int check_file(char* filename)
           return (0); /* file is ready for writing */
      else
           return (1); /* file is not ready for writing */
-}
\ No newline at end of file
+}