Author: Niko Tyni <ntyni@debian.org>
Last-Update: Fri, 11 Mar 2016 11:25:59 +0200
Bug-Debian: https://bugs.debian.org/812626
Description: Fix __timing initialization
 When Perl code passes a 'timing' parameter that is not a hash reference,
 for instance an undefined value, the '__timing' pointer passed to
 libfreecontact needs to be explicitly initialized.
 .
 This fixes segmentation faults in t/02test.t when built
 without optimization (gcc -O0).

--- a/FreeContact.xsp
+++ b/FreeContact.xsp
@@ -91,7 +91,10 @@ predictor::_run( __ali, __cp, __density,
     time_res_t timing;
   CODE:
     try {
-      if(items>=17 && SvROK(ST(16)) && SvTYPE(SvRV(ST(16))) == SVt_PVHV) __timing = &timing;
+      if(items>=17) {
+        if (SvROK(ST(16)) && SvTYPE(SvRV(ST(16))) == SVt_PVHV) __timing = &timing;
+        else __timing = NULL;
+      }
       RETVAL = THIS->run( __ali, __cp, __density, __gapth, __mincontsep, __pseudocnt, __pscnt_weight, __estimate_ivcov, __shrink_lambda, __cov20, __apply_gapth, __rho, __veczw, __num_threads, __icme_timeout, __timing );
     }
     catch (freecontact::icme_timeout_error& e)
@@ -116,7 +119,10 @@ predictor::_run_with_seq_weights(ali_t&
     time_res_t timing;
   CODE:
     try {
-      if(items>=17 && SvROK(ST(16)) && SvTYPE(SvRV(ST(16))) == SVt_PVHV) __timing = &timing;
+      if(items>=17) {
+        if (SvROK(ST(16)) && SvTYPE(SvRV(ST(16))) == SVt_PVHV) __timing = &timing;
+        else __timing = NULL;
+      }
       RETVAL = THIS->run( __ali, __aliw, __wtot,
         __density, __gapth, __mincontsep,
         __pseudocnt, __pscnt_weight, __estimate_ivcov, __shrink_lambda,
