Zum Hauptinhalt springen
LIVE
CVSS 4.8CVE-2026-137621 | A weakness has been identified in RT-Thread up to 5.3.0. Affected by this vulnerability is the function bl_adc_get_value of the file bsp/bouffalo_lab/libraries/rt_drivers/drv_adc.c of the component Bouffalo ADC Driver. This manipulation of the argument channel causes improper validation of array index. The attack requires local access. Patch name: b3a0eb5e12c6dca8145fc49d76c4785478c9e55b. It is suggested to install a patch to address this issue.CVSS 6.7CVE-2026-137620 | A security flaw has been discovered in RT-Thread up to 5.3.0. Affected is the function davinci_spi_get_prescale of the file bsp/dm365/drivers/spi-davinci.c of the component DM365 SPI Driver. The manipulation of the argument max_hz results in divide by zero. The attack requires a local approach. The exploit has been released to the public and may be used for attacks. The patch is identified as e12183f7b87eddf182b95bf8b400acd626880306. Applying a patch is adviCVSS 4.8CVE-2026-137618 | A vulnerability was identified in RT-Thread up to 5.3.0. This impacts the function hpm_adc_enabled of the file bsp/hpmicro/libraries/drivers/drv_adc.c of the component HPM ADC Driver. The manipulation of the argument channel leads to improper validation of array index. The attack needs to be performed locally. The exploit is publicly available and might be used. The identifier of the patch is fc64f78669b42b35981f97c23c7e952832f3b48b. It is recommended to appCVSS 8.5CVE-2026-137506 | ezdxf through 1.4.5 contains a code injection vulnerability in the dxf2code add-on that allows attackers to inject Python code via unescaped single quotes in DXF table entry names. Attackers can craft a DXF file whose layer, linetype, style, or appid names break out of quoted strings in generated scripts, executing code with the privileges of the user running them.CVSS 7.1CVE-2026-137507 | torchvision before 0.29.2 contains a path traversal vulnerability in _extract_tar() that allows attackers to write files outside the extraction directory by supplying crafted tar archives. Attackers controlling archives passed to extract_archive() or download_and_extract_archive() can use .. paths, absolute paths, or symlinks to overwrite Python modules and achieve code execution.CVSS 8.5CVE-2026-137518 | pyfda through 0.9.5 contains an insecure deserialization vulnerability in load_filter() that allows attackers to execute code by supplying crafted .npz or .pkl filter files. Attackers can embed a __reduce__ gadget that runs via np.load with allow_pickle=True or pickle.load before validation, executing code with the user's privileges.CVSS 8.5CVE-2026-137529 | JAL (Just Another Ledger) through 2026.11.3 contains an arbitrary file overwrite vulnerability in backup restore that allows attackers to write files by supplying a crafted .tgz backup with a symlink member. Attackers can include a jal.sqlite symlink to an absolute path followed by a regular jal.sqlite member, overwriting files such as shell startup scripts for code execution.CVSS 8.7CVE-2026-137539 | lastversion before 3.6.20 contains a path traversal vulnerability in extract_tar() that allows attackers to write files outside the extraction directory via tar symlink members. Attackers controlling a project's release assets can craft a tarball with a symlink followed by a file beneath it, writing files like usercustomize.py to achieve code execution.
Alle im Drawer
Intelligence View
⚡ tsecurity.de Intelligence

# Understanding JavaScript Closures Through Call Stack, Heap Memory & `[[Scopes]]`

Closures aren't magic—they're simply JavaScript's way of keeping data alive when a function still needs it. Every JavaScript developer has heard statements l…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Quelle & Fakten · 4 Min. Lesezeit
Quelle: dev.to
Rubrik: Programmation sécurisée

Closures aren't magic—they're simply JavaScript's way of keeping data alive when a function still needs it.




Every JavaScript developer has heard statements like:




  • "A closure is a function that remembers variables from its outer scope."

  • "The inner function closes over variables."

  • "Closures preserve the lexical environment."



But...




  • How does a function actually remember variables?

  • Where are those variables stored after the outer function finishes?

  • Why doesn't JavaScript delete them?



Let's go beyond the textbook definition and see what actually happens inside the JavaScript engine.









The Two Main Players Inside the JavaScript Engine



Whenever a function executes, two important memory areas are involved:




  • Call Stack

  • Heap Memory



Understanding closures is really about understanding where JavaScript stores variables and why some of them survive after a function finishes executing.









1. What Happens in a Normal Function?



Consider a simple function:




function greet() {
let name = "JavaScript";
console.log(name);
}

greet();






When greet() executes:




  1. An Execution Context is created.

  2. Local variables (name) belong to that execution.

  3. The execution context is pushed onto the Call Stack.




Call Stack

┌─────────────────────────┐
│ Execution Context │
│ name = "JavaScript" │
└─────────────────────────┘






After the function finishes:




  • The execution context is popped off the stack.

  • No code references name anymore.

  • It becomes eligible for Garbage Collection.



Everything is cleaned up.









2. What Changes When a Closure Is Created?



Now look at this example:




function outerFunction() {

let count = 0;

function innerFunction() {
count++;
console.log(count);
}

return innerFunction;
}

const counter = outerFunction();

counter();
counter();
counter();






Output




1
2
3






But wait...



outerFunction() already finished executing.



Its execution context has been removed from the Call Stack.



So why is count still available?



That's where closures come in.









Behind the Scenes



When JavaScript notices that innerFunction uses count, it understands:




"This variable will still be needed after outerFunction() returns."




Instead of letting count disappear with the execution context, the engine keeps it alive.



Three important things happen behind the scenes.









Step A — Captured Variables Are Kept in Heap Memory



The variables that are captured by an inner function are stored inside an internal object called the Lexical Environment (often called the Closure Context).



Conceptually, you can think of it like this:




Heap Memory

Lexical Environment

{
count: 0
}






Unlike the Call Stack, heap memory isn't destroyed when the function returns.



This allows the captured variables to stay alive.




Note: Engines don't literally "move" variables from the stack to the heap. Instead, captured variables are stored in a heap-allocated lexical environment so they can outlive the function call.










Step B — The Secret Link ([[Scopes]])



Every function internally carries a hidden reference called:




[[Scopes]]






This hidden reference points to the lexical environment containing the variables it needs.



Conceptually:




counter
│
▼
[[Scopes]]
│
▼
Lexical Environment
{
count: 0
}






Even after outerFunction() has finished, the returned function still knows exactly where count lives.









Step C — The Scope Chain



Later, when you execute:




counter();






JavaScript performs variable lookup in this order:




  1. Check the function's local scope.

  2. If not found, follow [[Scopes]].

  3. Search the lexical environment.

  4. Continue upward until the variable is found.



This lookup process is called the Scope Chain.









Visualizing the Entire Process






Before outerFunction() Returns






Call Stack

┌────────────────────────────┐
│ outerFunction() │
│ count = 0 │
│ innerFunction() │
└────────────────────────────┘












After Returning






Call Stack

┌──────────────────────┐
│ Global Execution │
└──────────────────────┘


Heap Memory

┌────────────────────────┐
│ Lexical Environment │
│ count = 0 │
└────────────────────────┘

▲
│
[[Scopes]]
│
▼

innerFunction






The execution context is gone.



The variable survives because the returned function still references it.









A Simple Analogy



Imagine:





  • outerFunction() is a hotel room.


  • count is an important document.

  • Before checking out, you place the document in a secure locker (Heap Memory).

  • You hand the locker key ([[Scopes]]) to your child (innerFunction).



Even after the hotel room is empty, your child still has the key and can access the document whenever needed.



That's exactly how closures work.









Why Are Closures Useful?






1. Data Privacy



Closures let you create private variables.




function createCounter() {

let count = 0;

return {
increment() {
count++;
},

getCount() {
return count;
}
};
}






Nobody outside can directly modify count.









2. Maintaining State



Closures allow functions to remember information between calls.




const counter = outerFunction();

counter();
counter();
counter();






The value of count persists without using global variables.









Key Takeaways



✔ A closure is created when an inner function uses variables from its outer scope.



✔ JavaScript keeps those captured variables alive inside a heap-allocated lexical environment.



✔ The returned function stores a hidden reference called [[Scopes]] to that environment.



✔ As long as the function exists, the captured variables cannot be garbage collected.



✔ Variable lookup through these linked environments is called the Scope Chain.









Final Thought



Closures aren't magic.



They're simply the JavaScript engine preserving the variables that are still needed.



Once you understand the relationship between the Call Stack, Heap Memory, Lexical Environment, and the hidden [[Scopes]] reference, closures become one of the most elegant and powerful features of JavaScript.

Information ergänzen Fachhinweis, Update, Korrektur oder Quelle zur Meldung beitragen
Gäste-Hinweise werden kurz redaktionell geprüft und danach hier angezeigt.

Community-Hinweise zur Meldung

0 freigegeben
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:

💬 Discussion communautaire et commentaires

🌐 Rejoindre le chat principal

Lancez la discussion dans le flux diffusé du Social Chat ou proposez ci-dessus une contribution experte via le formulaire de complément.

Évaluation communautaire & preuve sociale
⭐ Avis des lecteurs
–
Ø / 5.0
Pas encore d'évaluation des lecteurs
Cet article vous a-t-il été utile ?
0
Donner votre évaluation
Évaluation détaillée (facultatif)
Contenu & qualité
Source & fiabilité
Actualité
Briefing sécurité Gratuit · désabonnement en 1 clic

Intelligence Digest — gratuit

Chaque jour, les principales actualités sécurité · résiliable à tout moment

Groupes d’histoires apparentées & sources (IA vectorielle)

6 Cluster
21 sources
Dyson may have just won Black Friday with a 59% discount on the V8 Cyclone — now just AU$268
Latest from TechRadar il y a 21 min.
20 autres sources
Latest from TechRadaril y a 1 hThese are the best Nintendo Switch 2 Black Friday deals in Australia right now — save up to AU$142 on the latest console Latest from TechRadaril y a 1 hWant the best bang for your buck? Tune in to our Black Friday livestream for the best deals in tech — from Apple and Samsung to LG, Nintendo and beyond Giga.deil y a 1 hBlack-Friday-Sale bei Teufel: bis zu 500 Euro Rabatt auf die beliebten Sound-Bestseller PC-WELTil y a 1 hAmazon startet Glücksrad am Black Friday: 10 Gutscheine im Wert von 2.000 Euro zu gewinnen PC-WELTil y a 1 hAmazon startet Glücksrad am Black Friday: 10 Gutscheine im Wert von 2.000 Euro zu gewinnen Latest from TechRadaril y a 2 hBlack Friday Pre-sale checklist – do these 5 things before you start shopping Latest from TechRadaril y a 2 hThe Breville coffee machine we rely on in the TechRadar Australia kitchen is now AU$1,100 off for Black Friday Latest from TechRadaril y a 2 hBlack Friday US smartwatch deals 2026 — all picked by a wearable tech expert CNETil y a 2 hI Found a Black Friday Deal That Takes $1,500 Off CNET’s Top-Rated 4K Laser Projector Latest from TechRadaril y a 2 hStop guessing which PS5 accessory to buy and take our Black Friday deal quiz Latest from TechRadaril y a 3 hThe only thing not affected by AI this Black Friday? Gaming monitors! Here's how to bag yourself a bargain OS X Dailyil y a 3 hBlack Friday Deals: $400 Off M5 MacBook Air! AirPods Pro 3 for $149! Latest from TechRadaril y a 4 hThe 2TB Samsung T9 portable SSD is $170 off this Black Friday Latest from TechRadaril y a 4 hThe best early Black Friday Fitbit and Google Pixel Watch deals CNETil y a 4 hBuying a Kindle on Black Friday? We Compare Amazon’s E-Readers to Help You Choose the Best One Latest from TechRadaril y a 4 hThis Black Friday Apple Mac mini M6 deal is the one I’d buy — it’s nearly the same spec as a MacBook Pro for $1,000 cheaper Latest from TechRadaril y a 4 hThe best value Apple Watch deal this Black Friday is the brand new Series 12 Latest from TechRadaril y a 4 hBlack Friday 75-inch TV deals: save on LG, TCL, Hisense, Samsung, Roku and Amazon TVs Latest from TechRadaril y a 4 hRayNeo's GT AR glasses are $249 for Black Friday, a big-screen workspace you can give every remote and traveling employee for under $250 Latest from TechRadaril y a 4 hAmazon's Black Friday sale is live for Australia and I'm hunting the top deals — these are my picks for the 70+ best discounts
Articles similaires
🔍 Verwandte News

Auch interessante Nachrichten # Understanding JavaScript Closures Through Call Stack, Heap Memory & `[[Scopes]]`

Thematisch verwandte Begriffe: Understanding, JavaScript, Closures, Through · 6 Treffer

Laden...

Chargement des vidéos ...

Laden...

Chargement des articles ...

Laden...

Chargement des vidéos ...

Laden...

Chargement des articles ...

Laden...

Chargement des vidéos ...

Laden...

Chargement des articles ...

Laden...

Chargement des vidéos ...

Laden...

Chargement des articles ...

Laden...

Chargement des vidéos ...

💬 Chargement des commentaires…
Sentinel CTI: ONLINE
Tirer pour actualiser
Widgets & Topics
Loading widgets…
Nächster Beitrag