ram_fs: avoid Deref_unconstructed_object exception

if ROM is invalid. With the patch one gets a name of the ROM and the
server continues.
This commit is contained in:
Alexander Boettcher 2017-02-23 15:05:36 +01:00 committed by Christian Helmuth
parent 6c723fb1e8
commit 28b359703d
1 changed files with 3 additions and 1 deletions

View File

@ -18,7 +18,6 @@
#include <base/attached_rom_dataspace.h>
#include <base/heap.h>
#include <root/component.h>
#include <base/attached_rom_dataspace.h>
#include <os/session_policy.h>
/* local includes */
@ -619,6 +618,9 @@ static void preload_content(Genode::Env &env,
/* read file content from ROM module */
try {
Attached_rom_dataspace rom(env, name);
if (!rom.valid())
throw Rm_session::Attach_failed();
File *file = new (&alloc) File(alloc, as);
file->write(rom.local_addr<char>(), rom.size(), 0);
dir.adopt_unsynchronized(file);