diff --git a/share/qtcreator/gdbmacros/dumper.py b/share/qtcreator/gdbmacros/dumper.py
index 54a6932742474fc30f81ceee36a6204022e7bc39..c10437e69c002275d48e1e23f91c8e53fcfa8672 100644
--- a/share/qtcreator/gdbmacros/dumper.py
+++ b/share/qtcreator/gdbmacros/dumper.py
@@ -546,9 +546,11 @@ class FrameCommand(gdb.Command):
                 # Special handling for char** argv.
                 n = 0
                 p = item.value
-                while not isNull(p.dereference()) and n <= 100:
-                    p += 1
-                    n += 1
+                # p is 0 for "optimized out" cases.
+                if not isNull(p):
+                    while not isNull(p.dereference()) and n <= 100:
+                        p += 1
+                        n += 1
 
                 d.beginHash()
                 d.put('iname="%s",' % item.iname)