--- rxvt-unicode/src/rxvtfont.C 2012/01/17 20:44:16 1.184 +++ rxvt-unicode/src/rxvtfont.C 2012/01/26 13:08:51 1.188 @@ -24,7 +24,7 @@ #include "rxvtutil.h" #include "rxvtfont.h" -#include +#include #include @@ -1501,7 +1501,7 @@ (*i)->unref (); for (pagemap **p = fmap.begin (); p != fmap.end (); p++) - delete *p; + delete [] *p; free (fontdesc); fontdesc = 0; @@ -1787,7 +1787,14 @@ if (!fmap[hi]) { - fmap[hi] = (pagemap *)new pagemap; + // we use [1] here because C++ has no separate new and new [] forms, + // and pagemap is char[256], so new incorrectly assumes we want to + // allocate an array of chars instead of a single pagemap. + // we can either cast the resulting pointer to (pagemap *) or + // allocate an array of pagemaps, returning a pointer to the first member + // this is no extra overhead, as new even allocates an array for + // "new pagemap" + fmap[hi] = new pagemap[1]; memset (fmap[hi], 0xff, sizeof (pagemap)); }