summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/area.c15
-rw-r--r--src/xml.c12
2 files changed, 24 insertions, 3 deletions
diff --git a/src/area.c b/src/area.c
index 7e7f3ed..4f0bc11 100644
--- a/src/area.c
+++ b/src/area.c
@@ -12,6 +12,10 @@ area_new(struct map *map)
{
struct area *a;
+ if (map == NULL) {
+ return NULL;
+ }
+
a = malloc(sizeof(*a));
if (a == NULL) {
return NULL;
@@ -126,6 +130,10 @@ render_area_to_viewport(struct area *area, struct viewport *vp)
SDL_Rect srcrect;
SDL_Rect dstrect;
+ if (area == NULL || vp == NULL) {
+ return;
+ }
+
srcrect.x = vp->x;
srcrect.y = vp->y;
srcrect.w = vp->w;
@@ -146,6 +154,13 @@ render_area_to_surface(struct area *area, SDL_Rect *arearect,
/* For demo */
SDL_Rect tmprect;
+ if (area == NULL || arearect == NULL) {
+ return;
+ }
+ if (surface == NULL || surfacerect == NULL) {
+ return;
+ }
+
memcpy(&srcrect, arearect, sizeof(srcrect));
memcpy(&dstrect, surfacerect, sizeof(dstrect));
diff --git a/src/xml.c b/src/xml.c
index e677fe1..d34b0ac 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -126,9 +126,15 @@ xml_node_pop(XML_Parser p)
free(n);
n = (struct xml_node *) XML_GetUserData(p);
- XML_SetStartElementHandler(p, n->start);
- XML_SetEndElementHandler(p, n->end);
- XML_SetCharacterDataHandler(p, n->charhndl);
+ if (n == NULL) {
+ XML_SetStartElementHandler(p, NULL);
+ XML_SetEndElementHandler(p, NULL);
+ XML_SetCharacterDataHandler(p, NULL);
+ } else {
+ XML_SetStartElementHandler(p, n->start);
+ XML_SetEndElementHandler(p, n->end);
+ XML_SetCharacterDataHandler(p, n->charhndl);
+ }
return data;
}