]> git.tuebingen.mpg.de Git - paraslash.git/commit
file_write: Fix NULL pointer dereference.
authorAndre Noll <maan@systemlinux.org>
Thu, 4 Nov 2010 22:34:33 +0000 (23:34 +0100)
committerAndre Noll <maan@systemlinux.org>
Tue, 23 Nov 2010 16:39:11 +0000 (17:39 +0100)
commit7d037b0b440e1913776650dbe35dbac6d5cfb5d5
tree072b61c9a522ef7fc97531bf8d88d9b51c70904d
parent12123ab5a95a0f31385e9615d36056cb6546aced
file_write: Fix NULL pointer dereference.

register_writer_node() is the only caller of the ->open method for paraslash
writers. It does not check its return value, which is OK for alsa, oss and osx
as these writer's ->open method always succeeds. However, the ->open() method
of the file writer may fail, for example because the output file could not be
opened. This error will be ignored and the writer node task is registered as
usual with ->fd being initialized to zero.

Fix this bug by splitting the ->open method of the file writer into the part which
merely allocates the private_file_write_data structure, hence always succeeds,
and the part which actually opens the output file. This second part is called later
from ->post_select as soon as there is data available to be written.

After this patch the ->open methods of all writers always succeed and we
may change its return value to void which is done in the next patch.
file_write.c