Browse Source

confdb: check if find_iter_context returned NULL

If so, we will return error to library. This shouldn't happen as long as
library user isn't overwriting memory.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Jan Friesse 12 years ago
parent
commit
e64437447f
1 changed files with 10 additions and 0 deletions
  1. 10 0
      lib/confdb.c

+ 10 - 0
lib/confdb.c

@@ -712,12 +712,17 @@ cs_error_t confdb_object_find_destroy(
 	}
 	}
 
 
 	context = find_iter_context(&confdb_inst->object_find_head, parent_object_handle);
 	context = find_iter_context(&confdb_inst->object_find_head, parent_object_handle);
+	if (context == NULL) {
+		error = CS_ERR_LIBRARY;
+		goto error_exit;
+	}
 	error = do_find_destroy(confdb_inst, context->find_handle);
 	error = do_find_destroy(confdb_inst, context->find_handle);
 	if (error == CS_OK) {
 	if (error == CS_OK) {
 		list_del(&context->list);
 		list_del(&context->list);
 		free(context);
 		free(context);
 	}
 	}
 
 
+error_exit:
 	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 	return error;
 	return error;
 }
 }
@@ -736,12 +741,17 @@ cs_error_t confdb_object_iter_destroy(
 	}
 	}
 
 
 	context = find_iter_context(&confdb_inst->object_iter_head, parent_object_handle);
 	context = find_iter_context(&confdb_inst->object_iter_head, parent_object_handle);
+	if (context == NULL) {
+		error = CS_ERR_LIBRARY;
+		goto error_exit;
+	}
 	error = do_find_destroy(confdb_inst, context->find_handle);
 	error = do_find_destroy(confdb_inst, context->find_handle);
 	if (error == CS_OK) {
 	if (error == CS_OK) {
 		list_del(&context->list);
 		list_del(&context->list);
 		free(context);
 		free(context);
 	}
 	}
 
 
+error_exit:
 	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 	(void)hdb_handle_put (&confdb_handle_t_db, handle);
 	return error;
 	return error;
 }
 }