Skip to content

Commit 39d1696

Browse files
committed
Fix bukka#23: Segmentation fault after fann_destroy
1 parent 3ca0916 commit 39d1696

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

fann.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,7 @@ PHP_FUNCTION(fann_destroy)
16201620
return;
16211621
}
16221622

1623-
RETURN_BOOL(PHPC_RES_DELETE(z_ann) == SUCCESS);
1623+
RETURN_BOOL(PHPC_RES_CLOSE(z_ann) == SUCCESS);
16241624
}
16251625
/* }}} */
16261626

@@ -2245,7 +2245,7 @@ PHP_FUNCTION(fann_destroy_train)
22452245
return;
22462246
}
22472247

2248-
RETURN_BOOL(PHPC_RES_DELETE(z_train_data) == SUCCESS);
2248+
RETURN_BOOL(PHPC_RES_CLOSE(z_train_data) == SUCCESS);
22492249
}
22502250
/* }}} */
22512251

phpc

Submodule phpc updated 1 file

tests/bug23.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Test bug
3+
--FILE--
4+
<?php
5+
$num_input = 2;
6+
$num_output = 1;
7+
$num_layers = 3;
8+
$num_neurons_hidden = 3;
9+
$ann = fann_create_standard($num_layers, $num_input, $num_neurons_hidden, $num_output);
10+
// destroy is the key - there is no segfault without it
11+
fann_destroy($ann);
12+
$ann = fann_create_standard($num_layers, $num_input, $num_neurons_hidden, $num_output);
13+
var_dump($ann);
14+
// now any accesss will segfault
15+
var_dump(fann_get_errno($ann));
16+
17+
?>
18+
--EXPECTF--
19+
resource(%d) of type (FANN)
20+
int(0)

0 commit comments

Comments
 (0)