diff options
author | Thomas White <taw@bitwiz.org.uk> | 2016-02-28 15:15:11 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2016-02-28 15:15:11 +0100 |
commit | d3cabf1f4a72d64a1da12a4826bf4bea13e59289 (patch) | |
tree | 8f406a8ad7e7425f076242669703a55584512ca4 | |
parent | cfafd6eaced69313a0ffebc4f1dba9f6e99b2438 (diff) |
Prevent NULL dereference
-rw-r--r-- | src/boxvec.c | 2 | ||||
-rw-r--r-- | src/wrap.c | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/boxvec.c b/src/boxvec.c index 7cdd01c..f00a81c 100644 --- a/src/boxvec.c +++ b/src/boxvec.c @@ -85,6 +85,8 @@ struct wrap_box *bv_box(struct boxvec *vec, int i) struct wrap_box *bv_last(struct boxvec *vec) { + if ( vec == NULL ) return NULL; + if ( vec->boxes == NULL ) return NULL; return vec->boxes[vec->n_boxes-1]; } @@ -960,7 +960,9 @@ int wrap_contents(struct frame *fr) //distribute_spaces(line, wrap_w, rho); /* Strip any sentinel boxes added by the wrapping algorithm */ - if ( bv_last(line->boxes)->type == WRAP_BOX_SENTINEL ) { + if ( (bv_last(line->boxes) != NULL) + && (bv_last(line->boxes)->type == WRAP_BOX_SENTINEL) ) + { line->boxes->n_boxes--; } |