Fix for 387806 by Rob Bradford <rob@openedhand.com>
authorJohnny Jacob <jjohnny@src.gnome.org>
Sat, 11 Aug 2007 21:29:11 +0000 (21:29 +0000)
committerJohnny Jacob <jjohnny@src.gnome.org>
Sat, 11 Aug 2007 21:29:11 +0000 (21:29 +0000)
svn path=/trunk/; revision=7938

camel/ChangeLog
camel/camel-text-index.c

index e804210..268a674 100644 (file)
@@ -1,4 +1,11 @@
 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
 
index 0a9952b..2effad6 100644 (file)
@@ -844,14 +844,16 @@ camel_text_index_new(const char *path, int flags)
        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);
@@ -859,6 +861,10 @@ camel_text_index_new(const char *path, int flags)
 
        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);
@@ -866,6 +872,10 @@ camel_text_index_new(const char *path, int flags)
 
        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);
@@ -873,6 +883,10 @@ camel_text_index_new(const char *path, int flags)
 
        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);
@@ -890,6 +904,10 @@ camel_text_index_new(const char *path, int flags)
        }
 
        return idx;
+
+fail:
+       camel_object_unref((CamelObject *)idx);
+       return NULL;
 }
 
 /* returns 0 if the index exists, is valid, and synced, -1 otherwise */