Skip to content
Snippets Groups Projects

ciolib_movetext: Do not leak fill buffer

Closed anonymouspage requested to merge anonymouspage/sbbs:fill-buffer-leak into master
  1. Oct 21, 2022
    • anonymouspage's avatar
      ciolib_puttext: free() is not reachable · b1cbde10
      anonymouspage authored
      As far as I can tell, this free() in ciolib_puttext() is not reachable
      given the current logic in the function; and, the value of buf is not
      modified by any called functions.
      
      Also, this function is invoked with stack allocated buffers, so it
      isn't safe to assume a free() is valid in this context. Better to let
      the owner of the buffer manage the lifecycle.
      b1cbde10
  2. Oct 19, 2022
    • anonymouspage's avatar
      ciolib_movetext: Plug fill buffer memory leak · 370669c0
      anonymouspage authored
      This fixes a memory leak in ciolib_movetext() which accumulates
      memory very quickly in scroll heavy ncurses environments. The
      problem was originally noticed while running syncterm, and
      confirmed with valgrind.
      
      valgrind confirmation:
      
       17,310,720 bytes in 368 blocks are definitely lost in loss record 128 of 128
          at 0x8C82899: malloc
          by 0x16E273: ciolib_movetext (ciolib.c:563)
          <<snip>>
      370669c0
Loading