null+****@clear*****
null+****@clear*****
2011年 11月 15日 (火) 10:13:46 JST
Susumu Yata 2011-11-15 01:13:46 +0000 (Tue, 15 Nov 2011)
New Revision: dedf19f1f56eb6225c6a9fba4e2bc4a659236383
Log:
fix a bug that appears if a given path is an empty string.
Modified files:
lib/dat.cpp
Modified: lib/dat.cpp (+8 -4)
===================================================================
--- lib/dat.cpp 2011-11-14 11:25:08 +0000 (5b67a79)
+++ lib/dat.cpp 2011-11-15 01:13:46 +0000 (d4678e4)
@@ -112,7 +112,7 @@ grn_dat_fin(grn_ctx *ctx, grn_dat *dat)
void
grn_dat_generate_trie_path(const char *base_path, char *trie_path, uint32_t file_id)
{
- if (!base_path) {
+ if (!base_path || !base_path[0]) {
trie_path[0] = '\0';
return;
}
@@ -218,9 +218,13 @@ grn_dat *
grn_dat_create(grn_ctx *ctx, const char *path, uint32_t,
uint32_t, uint32_t flags)
{
- if (path && (std::strlen(path) >= (PATH_MAX - (FILE_ID_LENGTH + 1)))) {
- ERR(GRN_FILENAME_TOO_LONG, const_cast<char *>("too long path"));
- return NULL;
+ if (path) {
+ if (path[0] == '\0') {
+ path = NULL;
+ } else if (std::strlen(path) >= (PATH_MAX - (FILE_ID_LENGTH + 1))) {
+ ERR(GRN_FILENAME_TOO_LONG, const_cast<char *>("too long path"));
+ return NULL;
+ }
}
grn_dat * const dat = static_cast<grn_dat *>(GRN_MALLOC(sizeof(grn_dat)));