gimp r25770 - trunk/plug-ins/script-fu/tinyscheme
- From: kcozens svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25770 - trunk/plug-ins/script-fu/tinyscheme
- Date: Thu, 22 May 2008 22:08:18 +0000 (UTC)
Author: kcozens
Date: Thu May 22 22:08:18 2008
New Revision: 25770
URL: http://svn.gnome.org/viewvc/gimp?rev=25770&view=rev
Log:
2008-05-22 Kevin Cozens <kcozens cvs gnome org>
* plug-ins/script-fu/tinyscheme/scheme.c: Added extra check to stop
"(let x 5)" syntax from causing seg fault in Linux. See bug #508020.
Removed some excess whitespace.
Modified:
trunk/plug-ins/script-fu/tinyscheme/scheme.c
Modified: trunk/plug-ins/script-fu/tinyscheme/scheme.c
==============================================================================
--- trunk/plug-ins/script-fu/tinyscheme/scheme.c (original)
+++ trunk/plug-ins/script-fu/tinyscheme/scheme.c Thu May 22 22:08:18 2008
@@ -2781,7 +2781,10 @@
}
if (is_symbol(car(sc->code))) { /* named let */
for (x = cadr(sc->code), sc->args = sc->NIL; x != sc->NIL; x = cdr(x)) {
-
+ if (!is_pair(x))
+ Error_1(sc, "Bad syntax of binding in let :", x);
+ if (!is_list(sc, car(x)))
+ Error_1(sc, "Bad syntax of binding in let :", car(x));
sc->args = cons(sc, caar(x), sc->args);
}
x = mk_closure(sc, cons(sc, reverse_in_place(sc, sc->NIL, sc->args), cddr(sc->code)), sc->envir);
@@ -3505,62 +3508,62 @@
}
static int is_list(scheme *sc, pointer a) {
- pointer slow, fast;
+ pointer slow, fast;
+
+ slow = fast = a;
+ while (1)
+ {
+ if (fast == sc->NIL)
+ return 1;
+ if (!is_pair(fast))
+ return 0;
+ fast = cdr(fast);
+ if (fast == sc->NIL)
+ return 1;
+ if (!is_pair(fast))
+ return 0;
+ fast = cdr(fast);
- slow = fast = a;
- while (1)
+ slow = cdr(slow);
+ if (fast == slow)
{
- if (fast == sc->NIL)
- return 1;
- if (!is_pair(fast))
- return 0;
- fast = cdr(fast);
- if (fast == sc->NIL)
- return 1;
- if (!is_pair(fast))
- return 0;
- fast = cdr(fast);
-
- slow = cdr(slow);
- if (fast == slow)
- {
- /* the fast pointer has looped back around and caught up
- with the slow pointer, hence the structure is circular,
- not of finite length, and therefore not a list */
- return 0;
- }
+ /* the fast pointer has looped back around and caught up
+ with the slow pointer, hence the structure is circular,
+ not of finite length, and therefore not a list */
+ return 0;
}
+ }
}
static int list_length(scheme *sc, pointer a) {
int i=0;
- pointer slow, fast;
+ pointer slow, fast;
- slow = fast = a;
- while (1)
+ slow = fast = a;
+ while (1)
+ {
+ if (fast == sc->NIL)
+ return i;
+ if (!is_pair(fast))
+ return i;
+ fast = cdr(fast);
+ ++i;
+ if (fast == sc->NIL)
+ return i;
+ if (!is_pair(fast))
+ return i;
+ ++i;
+ fast = cdr(fast);
+
+ slow = cdr(slow);
+ if (fast == slow)
{
- if (fast == sc->NIL)
- return i;
- if (!is_pair(fast))
- return i;
- fast = cdr(fast);
- ++i;
- if (fast == sc->NIL)
- return i;
- if (!is_pair(fast))
- return i;
- ++i;
- fast = cdr(fast);
-
- slow = cdr(slow);
- if (fast == slow)
- {
- /* the fast pointer has looped back around and caught up
- with the slow pointer, hence the structure is circular,
- not of finite length, and therefore not a list */
- return -1;
- }
+ /* the fast pointer has looped back around and caught up
+ with the slow pointer, hence the structure is circular,
+ not of finite length, and therefore not a list */
+ return -1;
}
+ }
}
static pointer opexe_3(scheme *sc, enum scheme_opcodes op) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]