Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bugfix: crash when mgr_create() failed

if no access permission to home dir, then mgr_create will failed.
  • Loading branch information...
commit 9deab15897edf7653353238adb39e82c2fc565af 1 parent efcb5a7
@davies davies authored
Showing with 8 additions and 0 deletions.
  1. +2 −0  src/bitcask.c
  2. +1 −0  src/diskmgr.c
  3. +5 −0 src/hstore.c
View
2  src/bitcask.c
@@ -62,6 +62,8 @@ Bitcask* bc_open(const char* path, int depth, int pos, time_t before)
}
const char* t[] = {path};
Mgr *mgr = mgr_create(t, 1);
+ if (mgr == NULL) return NULL;
+
Bitcask* bc = bc_open2(mgr, depth, pos, before);
bc_scan(bc);
return bc;
View
1  src/diskmgr.c
@@ -37,6 +37,7 @@ Mgr* mgr_create(const char **disks, int ndisks)
if (0 != access(disks[i], F_OK) && 0 != mkdir(disks[i], 0755)) {
free(mgr->disks);
free(mgr);
+ fprintf(stderr, "access %s failed\n", disks[i]);
return NULL;
}
mgr->disks[i] = strdup(disks[i]);
View
5 src/hstore.c
@@ -132,6 +132,10 @@ HStore* hs_open(char *path, int height, time_t before)
store->op_end = 0;
store->op_limit = 0;
store->mgr = mgr_create((const char**)paths, npath);
+ if (store->mgr == NULL) {
+ free(store);
+ return NULL;
+ }
store->bitcasks = (Bitcask**) malloc(sizeof(Bitcask*) * count);
memset(store->bitcasks, 0, sizeof(Bitcask*) * count);
for (i=0; i<NUM_OF_MUTEX; i++) {
@@ -153,6 +157,7 @@ HStore* hs_open(char *path, int height, time_t before)
}
}
Mgr *mgr = mgr_create((const char**)buf, npath);
+ if (mgr == NULL) return NULL;
store->bitcasks[i] = bc_open2(mgr, height, i, before);
}
for (i=0;i<npath;i++) {
Please sign in to comment.
Something went wrong with that request. Please try again.