Null Pointer Dereference in User Service
★★☆☆☆
📁 expressjs/express 🔢
def5678 Null Pointer ★★☆☆☆
Difficulty
+75 XP reward
file.js
| 1 | function getUserProfile(userId) { |
| 2 | const user = database.findUser(userId); |
| 3 | return { • No null check before accessing user properties |
| 4 | name: user.name, |
| 5 | email: user.email, |
| 6 | profile: user.profile.displayName • Potential null pointer on user.profile |
| 7 | }; |
| 8 | } |
Hints:
- • Line 3: No null check before accessing user properties
- • Line 6: Potential null pointer on user.profile
Submit Your Fix
Lines marked: 0
Click a marked line number below to edit its fix.
Click on lines in the diff above to mark them, then add your fixes here.