- if (OLDNUM_SIZE(SP_PARM) < screen_lines(SP_PARM)) {
- int *new_oldnums = typeRealloc(int, screen_lines(SP_PARM), oldnums(SP_PARM));
+ assert(OLDNUM_SIZE(SP_PARM) >= 0);
+ assert(screen_lines(SP_PARM) > 0);
+ if ((oldnums(SP_PARM) == 0)
+ || (OLDNUM_SIZE(SP_PARM) < screen_lines(SP_PARM))) {
+ int need_lines = ((OLDNUM_SIZE(SP_PARM) < screen_lines(SP_PARM))
+ ? screen_lines(SP_PARM)
+ : OLDNUM_SIZE(SP_PARM));
+ int *new_oldnums = typeRealloc(int,
+ (size_t) need_lines,
+ oldnums(SP_PARM));