Mercurial > vim
comparison src/screen.c @ 6959:87cb71d54e8a v7.4.797
patch 7.4.797
Problem: Crash when using more lines for the command line than
'maxcombine'.
Solution: Use the correct array index. Also, do not try redrawing when
exiting. And use screen_Columns instead of Columns.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sat, 25 Jul 2015 22:53:00 +0200 |
parents | 1efa7c2b9368 |
children | 5ea5bd9c18d2 |
comparison
equal
deleted
inserted
replaced
6958:8840c1ae3b50 | 6959:87cb71d54e8a |
---|---|
277 int | 277 int |
278 redraw_asap(type) | 278 redraw_asap(type) |
279 int type; | 279 int type; |
280 { | 280 { |
281 int rows; | 281 int rows; |
282 int cols = screen_Columns; | |
282 int r; | 283 int r; |
283 int ret = 0; | 284 int ret = 0; |
284 schar_T *screenline; /* copy from ScreenLines[] */ | 285 schar_T *screenline; /* copy from ScreenLines[] */ |
285 sattr_T *screenattr; /* copy from ScreenAttrs[] */ | 286 sattr_T *screenattr; /* copy from ScreenAttrs[] */ |
286 #ifdef FEAT_MBYTE | 287 #ifdef FEAT_MBYTE |
289 u8char_T *screenlineC[MAX_MCO]; /* copy from ScreenLinesC[][] */ | 290 u8char_T *screenlineC[MAX_MCO]; /* copy from ScreenLinesC[][] */ |
290 schar_T *screenline2 = NULL; /* copy from ScreenLines2[] */ | 291 schar_T *screenline2 = NULL; /* copy from ScreenLines2[] */ |
291 #endif | 292 #endif |
292 | 293 |
293 redraw_later(type); | 294 redraw_later(type); |
294 if (msg_scrolled || (State != NORMAL && State != NORMAL_BUSY)) | 295 if (msg_scrolled || (State != NORMAL && State != NORMAL_BUSY) || exiting) |
295 return ret; | 296 return ret; |
296 | 297 |
297 /* Allocate space to save the text displayed in the command line area. */ | 298 /* Allocate space to save the text displayed in the command line area. */ |
298 rows = Rows - cmdline_row; | 299 rows = screen_Rows - cmdline_row; |
299 screenline = (schar_T *)lalloc( | 300 screenline = (schar_T *)lalloc( |
300 (long_u)(rows * Columns * sizeof(schar_T)), FALSE); | 301 (long_u)(rows * cols * sizeof(schar_T)), FALSE); |
301 screenattr = (sattr_T *)lalloc( | 302 screenattr = (sattr_T *)lalloc( |
302 (long_u)(rows * Columns * sizeof(sattr_T)), FALSE); | 303 (long_u)(rows * cols * sizeof(sattr_T)), FALSE); |
303 if (screenline == NULL || screenattr == NULL) | 304 if (screenline == NULL || screenattr == NULL) |
304 ret = 2; | 305 ret = 2; |
305 #ifdef FEAT_MBYTE | 306 #ifdef FEAT_MBYTE |
306 if (enc_utf8) | 307 if (enc_utf8) |
307 { | 308 { |
308 screenlineUC = (u8char_T *)lalloc( | 309 screenlineUC = (u8char_T *)lalloc( |
309 (long_u)(rows * Columns * sizeof(u8char_T)), FALSE); | 310 (long_u)(rows * cols * sizeof(u8char_T)), FALSE); |
310 if (screenlineUC == NULL) | 311 if (screenlineUC == NULL) |
311 ret = 2; | 312 ret = 2; |
312 for (i = 0; i < p_mco; ++i) | 313 for (i = 0; i < p_mco; ++i) |
313 { | 314 { |
314 screenlineC[i] = (u8char_T *)lalloc( | 315 screenlineC[i] = (u8char_T *)lalloc( |
315 (long_u)(rows * Columns * sizeof(u8char_T)), FALSE); | 316 (long_u)(rows * cols * sizeof(u8char_T)), FALSE); |
316 if (screenlineC[i] == NULL) | 317 if (screenlineC[i] == NULL) |
317 ret = 2; | 318 ret = 2; |
318 } | 319 } |
319 } | 320 } |
320 if (enc_dbcs == DBCS_JPNU) | 321 if (enc_dbcs == DBCS_JPNU) |
321 { | 322 { |
322 screenline2 = (schar_T *)lalloc( | 323 screenline2 = (schar_T *)lalloc( |
323 (long_u)(rows * Columns * sizeof(schar_T)), FALSE); | 324 (long_u)(rows * cols * sizeof(schar_T)), FALSE); |
324 if (screenline2 == NULL) | 325 if (screenline2 == NULL) |
325 ret = 2; | 326 ret = 2; |
326 } | 327 } |
327 #endif | 328 #endif |
328 | 329 |
329 if (ret != 2) | 330 if (ret != 2) |
330 { | 331 { |
331 /* Save the text displayed in the command line area. */ | 332 /* Save the text displayed in the command line area. */ |
332 for (r = 0; r < rows; ++r) | 333 for (r = 0; r < rows; ++r) |
333 { | 334 { |
334 mch_memmove(screenline + r * Columns, | 335 mch_memmove(screenline + r * cols, |
335 ScreenLines + LineOffset[cmdline_row + r], | 336 ScreenLines + LineOffset[cmdline_row + r], |
336 (size_t)Columns * sizeof(schar_T)); | 337 (size_t)cols * sizeof(schar_T)); |
337 mch_memmove(screenattr + r * Columns, | 338 mch_memmove(screenattr + r * cols, |
338 ScreenAttrs + LineOffset[cmdline_row + r], | 339 ScreenAttrs + LineOffset[cmdline_row + r], |
339 (size_t)Columns * sizeof(sattr_T)); | 340 (size_t)cols * sizeof(sattr_T)); |
340 #ifdef FEAT_MBYTE | 341 #ifdef FEAT_MBYTE |
341 if (enc_utf8) | 342 if (enc_utf8) |
342 { | 343 { |
343 mch_memmove(screenlineUC + r * Columns, | 344 mch_memmove(screenlineUC + r * cols, |
344 ScreenLinesUC + LineOffset[cmdline_row + r], | 345 ScreenLinesUC + LineOffset[cmdline_row + r], |
345 (size_t)Columns * sizeof(u8char_T)); | 346 (size_t)cols * sizeof(u8char_T)); |
346 for (i = 0; i < p_mco; ++i) | 347 for (i = 0; i < p_mco; ++i) |
347 mch_memmove(screenlineC[i] + r * Columns, | 348 mch_memmove(screenlineC[i] + r * cols, |
348 ScreenLinesC[r] + LineOffset[cmdline_row + r], | 349 ScreenLinesC[i] + LineOffset[cmdline_row + r], |
349 (size_t)Columns * sizeof(u8char_T)); | 350 (size_t)cols * sizeof(u8char_T)); |
350 } | 351 } |
351 if (enc_dbcs == DBCS_JPNU) | 352 if (enc_dbcs == DBCS_JPNU) |
352 mch_memmove(screenline2 + r * Columns, | 353 mch_memmove(screenline2 + r * cols, |
353 ScreenLines2 + LineOffset[cmdline_row + r], | 354 ScreenLines2 + LineOffset[cmdline_row + r], |
354 (size_t)Columns * sizeof(schar_T)); | 355 (size_t)cols * sizeof(schar_T)); |
355 #endif | 356 #endif |
356 } | 357 } |
357 | 358 |
358 update_screen(0); | 359 update_screen(0); |
359 ret = 3; | 360 ret = 3; |
364 | 365 |
365 /* Restore the text displayed in the command line area. */ | 366 /* Restore the text displayed in the command line area. */ |
366 for (r = 0; r < rows; ++r) | 367 for (r = 0; r < rows; ++r) |
367 { | 368 { |
368 mch_memmove(current_ScreenLine, | 369 mch_memmove(current_ScreenLine, |
369 screenline + r * Columns, | 370 screenline + r * cols, |
370 (size_t)Columns * sizeof(schar_T)); | 371 (size_t)cols * sizeof(schar_T)); |
371 mch_memmove(ScreenAttrs + off, | 372 mch_memmove(ScreenAttrs + off, |
372 screenattr + r * Columns, | 373 screenattr + r * cols, |
373 (size_t)Columns * sizeof(sattr_T)); | 374 (size_t)cols * sizeof(sattr_T)); |
374 #ifdef FEAT_MBYTE | 375 #ifdef FEAT_MBYTE |
375 if (enc_utf8) | 376 if (enc_utf8) |
376 { | 377 { |
377 mch_memmove(ScreenLinesUC + off, | 378 mch_memmove(ScreenLinesUC + off, |
378 screenlineUC + r * Columns, | 379 screenlineUC + r * cols, |
379 (size_t)Columns * sizeof(u8char_T)); | 380 (size_t)cols * sizeof(u8char_T)); |
380 for (i = 0; i < p_mco; ++i) | 381 for (i = 0; i < p_mco; ++i) |
381 mch_memmove(ScreenLinesC[i] + off, | 382 mch_memmove(ScreenLinesC[i] + off, |
382 screenlineC[i] + r * Columns, | 383 screenlineC[i] + r * cols, |
383 (size_t)Columns * sizeof(u8char_T)); | 384 (size_t)cols * sizeof(u8char_T)); |
384 } | 385 } |
385 if (enc_dbcs == DBCS_JPNU) | 386 if (enc_dbcs == DBCS_JPNU) |
386 mch_memmove(ScreenLines2 + off, | 387 mch_memmove(ScreenLines2 + off, |
387 screenline2 + r * Columns, | 388 screenline2 + r * cols, |
388 (size_t)Columns * sizeof(schar_T)); | 389 (size_t)cols * sizeof(schar_T)); |
389 #endif | 390 #endif |
390 SCREEN_LINE(cmdline_row + r, 0, Columns, Columns, FALSE); | 391 SCREEN_LINE(cmdline_row + r, 0, cols, cols, FALSE); |
391 } | 392 } |
392 ret = 4; | 393 ret = 4; |
393 } | 394 } |
394 } | 395 } |
395 | 396 |