2007-08-12 Johnny Jacob <jjohnny@novell.com>
+
+ ** Fix for 387806 by Rob Bradford <rob@openedhand.com>
+
+ * camel-text-index.c: Add some checking of return values when
+ calling camel_block_file_new_block.
+
+2007-08-12 Johnny Jacob <jjohnny@novell.com>
** Fix for Bug 261084 from Jared Moore
p->links = camel_key_file_new(link, flags, CAMEL_TEXT_INDEX_KEY_VERSION);
if (p->blocks == NULL || p->links == NULL) {
- camel_object_unref((CamelObject *)idx);
- return NULL;
- }
+ goto fail;
rb = (struct _CamelTextIndexRoot *)p->blocks->root;
if (rb->word_index_root == 0) {
bl = camel_block_file_new_block(p->blocks);
+
+ if (bl == NULL)
+ goto fail;
+
rb->word_index_root = bl->id;
camel_block_file_unref_block(p->blocks, bl);
camel_block_file_touch_block(p->blocks, p->blocks->root_block);
if (rb->word_hash_root == 0) {
bl = camel_block_file_new_block(p->blocks);
+
+ if (bl == NULL)
+ goto fail;
+
rb->word_hash_root = bl->id;
camel_block_file_unref_block(p->blocks, bl);
camel_block_file_touch_block(p->blocks, p->blocks->root_block);
if (rb->name_index_root == 0) {
bl = camel_block_file_new_block(p->blocks);
+
+ if (bl == NULL)
+ goto fail;
+
rb->name_index_root = bl->id;
camel_block_file_unref_block(p->blocks, bl);
camel_block_file_touch_block(p->blocks, p->blocks->root_block);
if (rb->name_hash_root == 0) {
bl = camel_block_file_new_block(p->blocks);
+
+ if (bl == NULL)
+ goto fail;
+
rb->name_hash_root = bl->id;
camel_block_file_unref_block(p->blocks, bl);
camel_block_file_touch_block(p->blocks, p->blocks->root_block);
}
return idx;
+
+fail:
+ camel_object_unref((CamelObject *)idx);
+ return NULL;
}
/* returns 0 if the index exists, is valid, and synced, -1 otherwise */