Changeset 5c2ef5b


Ignore:
Timestamp:
Jul 3, 2011, 11:42:26 PM (13 years ago)
Author:
Jason Gross <jgross@mit.edu>
Children:
530c51c
Parents:
785ee77
Message:
Don't segfault when you expunge all messages from the messagelist

When we used owl_list, trying to get an element from an empty list would
return NULL.  When we moved to GPtrArray, we dropped this checking,
without dropping the assumption that, e.g.,
 owl_view_get_element(v, owl_global_get_curmsg(&g));
works everywhere.  This commit adds the logic back in to deal with this
case.

Additionally, don't segfault on things like :unpunt -1.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rca749a9 r5c2ef5b  
    24982498  } else if(argc == 2) {
    24992499    /* Handle :unpunt <number> */
    2500     if(unpunt && (i=atoi(argv[1])) !=0) {
     2500    if (unpunt && (i = atoi(argv[1])) > 0) {
    25012501      i--;      /* Accept 1-based indexing */
    25022502      if (i < fl->len) {
  • messagelist.c

    rfc8a87a r5c2ef5b  
    2222void *owl_messagelist_get_element(const owl_messagelist *ml, int n)
    2323{
     24  if (n >= ml->list->len) return NULL;
    2425  return ml->list->pdata[n];
    2526}
Note: See TracChangeset for help on using the changeset viewer.