aboutsummaryrefslogtreecommitdiff
path: root/src/gdbmsetopt.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-08-03 10:35:13 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2011-08-03 10:35:13 +0000
commit1862201e4c0031df0bdd3d06b582dbd6c19525e8 (patch)
tree4599d939b17f29f4ef11e77e4714b51bb790323f /src/gdbmsetopt.c
parent3d2a042617c643628ffc1088c013eef214d60803 (diff)
downloadgdbm-1862201e4c0031df0bdd3d06b582dbd6c19525e8.tar.gz
gdbm-1862201e4c0031df0bdd3d06b582dbd6c19525e8.tar.bz2
(gdbm_setopt): Avoid coredumps on NULL optval.
Diffstat (limited to 'src/gdbmsetopt.c')
-rw-r--r--src/gdbmsetopt.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/gdbmsetopt.c b/src/gdbmsetopt.c
index 5c7fbbd..d3b333b 100644
--- a/src/gdbmsetopt.c
+++ b/src/gdbmsetopt.c
@@ -28,7 +28,7 @@
int
gdbm_setopt(GDBM_FILE dbf, int optflag, int *optval, int optlen)
{
- switch(optflag)
+ switch (optflag)
{
case GDBM_CACHESIZE:
/* Optval will point to the new size of the cache. */
@@ -42,7 +42,7 @@ gdbm_setopt(GDBM_FILE dbf, int optflag, int *optval, int optlen)
case GDBM_FASTMODE:
/* Obsolete form of SYNCMODE. */
- if ((*optval != TRUE) && (*optval != FALSE))
+ if (!optval || ((*optval != TRUE) && (*optval != FALSE)))
{
gdbm_errno = GDBM_OPT_ILLEGAL;
return -1;
@@ -53,7 +53,7 @@ gdbm_setopt(GDBM_FILE dbf, int optflag, int *optval, int optlen)
case GDBM_SYNCMODE:
/* Optval will point to either true or false. */
- if ((*optval != TRUE) && (*optval != FALSE))
+ if (!optval || ((*optval != TRUE) && (*optval != FALSE)))
{
gdbm_errno = GDBM_OPT_ILLEGAL;
return -1;
@@ -64,7 +64,7 @@ gdbm_setopt(GDBM_FILE dbf, int optflag, int *optval, int optlen)
case GDBM_CENTFREE:
/* Optval will point to either true or false. */
- if ((*optval != TRUE) && (*optval != FALSE))
+ if (!optval || ((*optval != TRUE) && (*optval != FALSE)))
{
gdbm_errno = GDBM_OPT_ILLEGAL;
return -1;
@@ -75,7 +75,7 @@ gdbm_setopt(GDBM_FILE dbf, int optflag, int *optval, int optlen)
case GDBM_COALESCEBLKS:
/* Optval will point to either true or false. */
- if ((*optval != TRUE) && (*optval != FALSE))
+ if (!optval || ((*optval != TRUE) && (*optval != FALSE)))
{
gdbm_errno = GDBM_OPT_ILLEGAL;
return -1;

Return to:

Send suggestions and report system problems to the System administrator.