summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-05-23 22:57:54 (GMT)
committerGuido van Rossum <guido@python.org>1996-05-23 22:57:54 (GMT)
commitdd96ca77da357bd65eaa555a86d0de7c589f11a8 (patch)
tree90ed59bd55a2586b48f9066aec6817e917e68f6a /Modules
parent2c26cfe776f040c208fbc2f50871431d29747b7a (diff)
downloadcpython-dd96ca77da357bd65eaa555a86d0de7c589f11a8.zip
cpython-dd96ca77da357bd65eaa555a86d0de7c589f11a8.tar.gz
cpython-dd96ca77da357bd65eaa555a86d0de7c589f11a8.tar.bz2
Be more careful about default args.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/bsddbmodule.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/Modules/bsddbmodule.c b/Modules/bsddbmodule.c
index d6102e1..8cf674e 100644
--- a/Modules/bsddbmodule.c
+++ b/Modules/bsddbmodule.c
@@ -556,15 +556,16 @@ bsdbtopen(self, args)
int flags = O_RDONLY;
int mode = 0666;
int cachesize = 0;
- int maxkeypage;
- int minkeypage;
- int btflags;
- unsigned int psize;
- int lorder;
+ int maxkeypage = 0;
+ int minkeypage = 0;
+ int btflags = 0;
+ unsigned int psize = 0;
+ int lorder = 0;
if (!newgetargs(args, "s|siiiiiii",
- &file, &flag, &mode,
- &btflags, &cachesize, &maxkeypage, &minkeypage, &psize, &lorder))
+ &file, &flag, &mode,
+ &btflags, &cachesize, &maxkeypage, &minkeypage,
+ &psize, &lorder))
return NULL;
if (flag != NULL) {
/* XXX need a way to pass O_EXCL, O_EXLOCK, O_NONBLOCK, O_SHLOCK */
@@ -594,8 +595,10 @@ bsdbtopen(self, args)
}
}
return newdbbtobject(file, flags, mode,
- btflags, cachesize, maxkeypage, minkeypage, psize, lorder);
+ btflags, cachesize, maxkeypage, minkeypage,
+ psize, lorder);
}
+
static object *
bsdrnopen(self, args)
object *self;
@@ -606,16 +609,17 @@ bsdrnopen(self, args)
int flags = O_RDONLY;
int mode = 0666;
int cachesize = 0;
- int rnflags;
- unsigned int psize;
- int lorder;
- size_t reclen;
- char *bval;
- char *bfname;
+ int rnflags = 0;
+ unsigned int psize = 0;
+ int lorder = 0;
+ size_t reclen = 0;
+ char *bval = "";
+ char *bfname = NULL;
if (!newgetargs(args, "s|siiiiiiss",
- &file, &flag, &mode,
- &rnflags, &cachesize, &psize, &lorder, &reclen, &bval, &bfname))
+ &file, &flag, &mode,
+ &rnflags, &cachesize, &psize, &lorder,
+ &reclen, &bval, &bfname))
return NULL;
if (flag != NULL) {
/* XXX need a way to pass O_EXCL, O_EXLOCK, O_NONBLOCK, O_SHLOCK */
@@ -643,6 +647,11 @@ bsdrnopen(self, args)
return NULL;
#endif
}
+ else if (flag[1] != '\0') {
+ err_setstr(BsddbError,
+ "Flag char 2 should be 'l' or absent");
+ return NULL;
+ }
}
return newdbrnobject(file, flags, mode,
rnflags, cachesize, psize, lorder, bval[0], bfname);