Finally I have a valid reason to learn about memory management. It was also hella weird when encountering it.

  • da_cow (she/her)@feddit.orgOP
    link
    fedilink
    arrow-up
    8
    ·
    2 days ago

    I found the mistake. Since the country code char array only has a size of 2 it overwrites the \0 char causing the memory to leak.

    • silasmariner@programming.dev
      link
      fedilink
      arrow-up
      16
      ·
      2 days ago

      Usually what’s meant by a memory leak is memory that’s allocated but never freed. Writing outside of array allocation would usually be considered an overflow. Which sounds kinda similar but is not the same.