← Back to Challenges / Challenge #1

Memory Leak in Database Connection

★★★☆☆
📁 facebook/react 🔢 abc1234 Memory Safety
★★★☆☆
Difficulty
+100 XP reward
DatabaseConnector.js.js | 18 lines
Original (Buggy) Read-only
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class DatabaseConnector {
constructor(url) {
this.url = url;
this.connection = null;
}
connect() {
this.connection = createConnection(this.url);
}
query(sql) {
return this.connection.execute(sql);
}
disconnect() {
// Memory leak: connection never closed
}
}
Your Fix Editable
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
0 added 0 removed 0 changed
Click lines on the left to mark as buggy

Submit Your Fix

Lines marked: 0

Edit the code on the right panel above to fix the bugs. Changes are highlighted in real-time.

Removed   Changed   Added    Click lines on the left to mark buggy lines