Changeset fa3290d


Ignore:
Timestamp:
May 16, 2007, 10:21:30 PM (14 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
ec53338
Parents:
6933082
Message:
Do not initialize the colorpair manager array if we don't have
colors. More specifically, do not write into arrays we have not
allocated and segfault.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fmtext.c

    rd754b0a rfa3290d  
    701701    }
    702702  }
    703   for(i = 0; i < 8; i++) {
    704     short fg, bg;
    705     pair_content(i, &fg, &bg);
    706     cpmgr->pairs[fg+1][bg+1] = i;
     703  if (owl_global_get_hascolors(&g)) {
     704    for(i = 0; i < 8; i++) {
     705      short fg, bg;
     706      if (i >= COLORS) continue;
     707      pair_content(i, &fg, &bg);
     708      cpmgr->pairs[fg+1][bg+1] = i;
     709    }
    707710  }
    708711}
     
    711714void owl_fmtext_reset_colorpairs()
    712715{
    713   short i, j;
    714   owl_colorpair_mgr *cpmgr = owl_global_get_colorpair_mgr(&g);
    715   cpmgr->next = 8;
    716 
    717   // The test is <= because we allocated COLORS+1 entries.
    718   for(i = 0; i <= COLORS; i++) {
    719     for(j = 0; j <= COLORS; j++) {
    720       cpmgr->pairs[i][j] = -1;
    721     }
    722   }
    723   for(i = 0; i < 8; i++) {
    724     short fg, bg;
    725     pair_content(i, &fg, &bg);
    726     cpmgr->pairs[fg+1][bg+1] = i;
     716  if (owl_global_get_hascolors(&g)) {
     717    short i, j;
     718    owl_colorpair_mgr *cpmgr = owl_global_get_colorpair_mgr(&g);
     719    cpmgr->next = 8;
     720   
     721    // The test is <= because we allocated COLORS+1 entries.
     722    for(i = 0; i <= COLORS; i++) {
     723      for(j = 0; j <= COLORS; j++) {
     724        cpmgr->pairs[i][j] = -1;
     725      }
     726    }
     727    for(i = 0; i < 8; i++) {
     728      short fg, bg;
     729      if (i >= COLORS) continue;
     730      pair_content(i, &fg, &bg);
     731      cpmgr->pairs[fg+1][bg+1] = i;
     732    }
    727733  }
    728734}
Note: See TracChangeset for help on using the changeset viewer.