[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19246: bindings: void return function *can* trigger a segfault
From: |
Ludovic Courtès |
Subject: |
bug#19246: bindings: void return function *can* trigger a segfault |
Date: |
Mon, 01 Dec 2014 22:50:38 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
Hi,
Amirouche Boubekki <address@hidden> skribis:
> void process(SCM integer, SCM other) {
> int a = scm_to_int(integer);
> int b = scm_to_int(other);
> int i, c = 0;
>
> for (i = 0; i<1000; i++) {
> c = c + a + b;
> }
> }
>
>
> void init () {
> scm_c_define_gsubr("process", 2, 0, 0, process);
> }
Functions exposed to Scheme must always return ‘SCM’.
So ‘process’ above must be changed to return ‘SCM’, possibly the
SCM_UNSPECIFIED value since it’s a side-effecting function.
Thanks,
Ludo’.