Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Lots of pedantic error checking in Palacios proper, especially for memory
[palacios.git] / palacios / src / devices / curses_cons.c
index 742180a..af66d77 100644 (file)
@@ -242,19 +242,30 @@ static int cons_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg)
 
     /* allocate state */
     state = (struct cons_state *)V3_Malloc(sizeof(struct cons_state));
-    V3_ASSERT(state);
+
+    if (!state) {
+       PrintError("Cannot allocate curses state\n");
+       V3_Free(state);
+       return -1;
+    }
 
     state->frontend_dev = frontend;
     state->cols = 80;
     state->rows = 25;
     state->framebuf = V3_Malloc(state->cols * state->rows * BYTES_PER_COL);
 
+    if (!state->framebuf) {
+       PrintError("Cannot allocate frame buffer\n");
+       V3_Free(state);
+       return -1;
+    }
 
     /* open tty for screen display */
     state->cons = v3_console_open(vm, state->cols, state->rows);
 
     if (!state->cons) {
        PrintError("Could not open console\n");
+       V3_Free(state->framebuf);
        V3_Free(state);
        return -1;
     }
@@ -264,6 +275,7 @@ static int cons_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg)
 
     if (dev == NULL) {
        PrintError("Could not attach device %s\n", dev_id);
+       V3_Free(state->framebuf);
        V3_Free(state);
        return -1;
     }