Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Not widely known problem in programming? (Developers)

posted by bretjohn Homepage E-mail, Rio Rancho, NM, 29.03.2021, 20:03

> > I'd call this a type of "use after free".
>
> Yep, me too. The program is effectively using memory after it is
> considered "freed" back to the system.

They are both correct. You simply cannot reference a local variable from a different local procedure and expect it to be reliable (sometimes it will work and other times it won't). You can only reference local variables from within the same procedure that declared them -- that's why they are called local. In your example, you will either need to make "message" a global variable, or make Init and Display be the same procedure. You could also maybe do some sort of indirect referencing by passing pointers, but still need to make sure you aren't releasing memory before you try to reference it.

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 194 users online (0 registered, 194 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum