1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-24 04:15:36 +02:00

Fix likely crash in `stable-sort!'

* libguile/sort.c (scm_stable_sort_x): Properly handle zero-length
  vectors.
* test-suite/tests/sort.test ("stable-sort"): Add test for this case.
This commit is contained in:
Andreas Rottmann 2011-06-09 22:11:02 +02:00
parent e108c961fe
commit 589bc528bd
2 changed files with 13 additions and 3 deletions

View file

@ -1,5 +1,5 @@
;;;; sort.test --- tests Guile's sort functions -*- scheme -*-
;;;; Copyright (C) 2003, 2006, 2007, 2009 Free Software Foundation, Inc.
;;;; Copyright (C) 2003, 2006, 2007, 2009, 2011 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@ -73,5 +73,10 @@
;; in guile 1.8.0 and 1.8.1 this test failed, an empty list provoked a
;; wrong-type-arg exception (where it shouldn't)
(pass-if "empty list"
(eq? '() (stable-sort '() <))))
(eq? '() (stable-sort '() <)))
;; Ditto here, but up to 2.0.1 and 2.1.0 and invoking undefined
;; behavior (integer underflow) leading to crashes.
(pass-if "empty vector"
(equal? '#() (stable-sort '#() <))))