summaryrefslogtreecommitdiff
path: root/libguile/list.h
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2018-10-14 02:22:22 -0400
committerAndy Wingo <wingo@pobox.com>2019-05-23 16:01:13 +0200
commit5dcad70d993e68b0b175efff8c9b3b7477a74891 (patch)
tree270899c632272532054059c9a4223f5ef163bb2e /libguile/list.h
parent0c0a658c564c4c585d740c8ccf16b889f996ac3f (diff)
downloadguile-5dcad70d993e68b0b175efff8c9b3b7477a74891.tar.gz
Fix list validation of *list->bytevector procedures.
Fixes <https://bugs.gnu.org/32938>. Reported by Josh Datko <jbd@cryptotronix.com>. * libguile/validate.h (SCM_VALIDATE_LIST_COPYLEN) (SCM_VALIDATE_NONEMPTYLIST_COPYLEN): Use '!=' instead of '>=' to validate the result of 'scm_ilength' after it has been stored in the user variable 'cvar'. * test-suite/tests/bytevectors.test: Add tests. Use '#:use-module' instead of ':use-module' in 'define-module' form.
Diffstat (limited to 'libguile/list.h')
-rw-r--r--libguile/list.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/libguile/list.h b/libguile/list.h
index a494a480c..5ebcc8a82 100644
--- a/libguile/list.h
+++ b/libguile/list.h
@@ -1,7 +1,7 @@
#ifndef SCM_LIST_H
#define SCM_LIST_H
-/* Copyright 1995-1997,2000-2001,2003-2006,2008-2009,2018
+/* Copyright 1995-1997,2000-2001,2003-2006,2008-2009,2018-2019
Free Software Foundation, Inc.
This file is part of Guile.
@@ -88,16 +88,20 @@ SCM_API SCM scm_copy_tree (SCM obj);
SCM_ASSERT (scm_ilength (lst) > 0, lst, pos, FUNC_NAME); \
} while (0)
+/* Note: we use (cvar != -1) instead of (cvar >= 0) below
+ in case 'cvar' is of unsigned type. */
#define SCM_VALIDATE_LIST_COPYLEN(pos, lst, cvar) \
do { \
cvar = scm_ilength (lst); \
- SCM_ASSERT (cvar >= 0, lst, pos, FUNC_NAME); \
+ SCM_ASSERT (cvar != -1, lst, pos, FUNC_NAME); \
} while (0)
+/* Note: we use (cvar != -1) instead of (cvar >= 0) below
+ in case 'cvar' is of unsigned type. */
#define SCM_VALIDATE_NONEMPTYLIST_COPYLEN(pos, lst, cvar) \
do { \
cvar = scm_ilength (lst); \
- SCM_ASSERT (cvar >= 1, lst, pos, FUNC_NAME); \
+ SCM_ASSERT (cvar != -1, lst, pos, FUNC_NAME); \
} while (0)