changeset 148:21a0692ee656

msInit will now actually do something on failure
author Jonathan Pevarnek <pevarnj@gmail.com>
date Mon, 03 Oct 2011 17:56:15 -0400
parents 941be6358d95
children eb69d1caa83b
files src/os/memStack.c src/os/scall.c
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/memStack.c	Mon Oct 03 17:34:22 2011 -0400
+++ b/src/os/memStack.c	Mon Oct 03 17:56:15 2011 -0400
@@ -29,7 +29,8 @@
 
 MemStack* msInit()
 {
-	MemStack *new = malloc(sizeof(MemStack)); //TODO error checking?
+	MemStack *new = malloc(sizeof(MemStack));
+	if(!new) return NULL;
 	new->top = NULL;
 	return new;
 }
--- a/src/os/scall.c	Mon Oct 03 17:34:22 2011 -0400
+++ b/src/os/scall.c	Mon Oct 03 17:56:15 2011 -0400
@@ -37,8 +37,12 @@
 		case SVC_GETHEAP:
 			point = allocHeap(a, (void*)b);
 			if(!ms) ms = msInit();
-			msPush(ms, point);
-			pcb.registers[2] = (u64)point;
+			if(ms) {
+				msPush(ms, point);
+				pcb.registers[2] = (u64)point;
+			} else {
+				pcb.registers[2] = 0;
+			}
 			break;
 		default:
 			pcb.registers[2] = -1; //TODO HACK