[dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-save.c, 1.8,
1.9
cras at dovecot.org
cras at dovecot.org
Wed Apr 12 23:01:51 EEST 2006
Update of /var/lib/cvs/dovecot/src/lib-storage/index/dbox
In directory talvi:/tmp/cvs-serv30666
Modified Files:
dbox-save.c
Log Message:
Crashfix when saving fails before even opening the file
Index: dbox-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-save.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- dbox-save.c 12 Apr 2006 18:43:52 -0000 1.8
+++ dbox-save.c 12 Apr 2006 20:01:48 -0000 1.9
@@ -249,15 +249,17 @@
ctx->finished = TRUE;
- /* Make sure the file ends here (we could have been overwriting some
- existing aborted mail). In case we failed, truncate the file to
- the size before writing. */
- if (ftruncate(ctx->file->fd, ctx->failed ? ctx->hdr_offset :
- ctx->file->output->offset) < 0) {
- mail_storage_set_critical(STORAGE(ctx->mbox->storage),
- "ftruncate(%s) failed: %m",
- ctx->file->path);
- ctx->failed = TRUE;
+ if (ctx->file != NULL) {
+ /* Make sure the file ends here (we could have been overwriting
+ some existing aborted mail). In case we failed, truncate the
+ file to the size before writing. */
+ if (ftruncate(ctx->file->fd, ctx->failed ? ctx->hdr_offset :
+ ctx->file->output->offset) < 0) {
+ mail_storage_set_critical(STORAGE(ctx->mbox->storage),
+ "ftruncate(%s) failed: %m",
+ ctx->file->path);
+ ctx->failed = TRUE;
+ }
}
if (!ctx->failed) {
More information about the dovecot-cvs
mailing list