diff --git a/ChangeLog b/ChangeLog index 6cf88e126e..dedf2afa85 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-12-11 Kevin Cozens + + * plug-ins/script-fu/tinyscheme/scheme.c (get_consecutive_cells): + Fix to prevent reporting out of memory when there should be plenty + of cells still available. See SourceForge bug #1794369. + 2007-12-11 Kevin Cozens * plug-ins/script-fu/tinyscheme/scheme.c: Don't abort the top-level diff --git a/plug-ins/script-fu/tinyscheme/scheme.c b/plug-ins/script-fu/tinyscheme/scheme.c index 17ed7f22b0..fe2710cca0 100644 --- a/plug-ins/script-fu/tinyscheme/scheme.c +++ b/plug-ins/script-fu/tinyscheme/scheme.c @@ -723,31 +723,30 @@ static pointer reserve_cells(scheme *sc, int n) { static pointer get_consecutive_cells(scheme *sc, int n) { pointer x; - if(sc->no_memory) { - return sc->sink; - } + if (sc->no_memory) { return sc->sink; } /* Are there any cells available? */ x=find_consecutive_cells(sc,n); - if (x == sc->NIL) { - /* If not, try gc'ing some */ - gc(sc, sc->NIL, sc->NIL); - x=find_consecutive_cells(sc,n); - if (x == sc->NIL) { - /* If there still aren't, try getting more heap */ - if (!alloc_cellseg(sc,1)) { - sc->no_memory=1; - return sc->sink; - } - } - x=find_consecutive_cells(sc,n); - if (x == sc->NIL) { - /* If all fail, report failure */ + if (x != sc->NIL) { return x; } + + /* If not, try gc'ing some */ + gc(sc, sc->NIL, sc->NIL); + x=find_consecutive_cells(sc,n); + if (x != sc->NIL) { return x; } + + /* If there still aren't, try getting more heap */ + if (!alloc_cellseg(sc,1)) + { sc->no_memory=1; return sc->sink; } - } - return (x); + + x=find_consecutive_cells(sc,n); + if (x != sc->NIL) { return x; } + + /* If all fail, report failure */ + sc->no_memory=1; + return sc->sink; } static int count_consecutive_cells(pointer x, int needed) {