summaryrefslogtreecommitdiff
path: root/core/apps/embeddedkonsole
authorerik <erik>2007-01-26 20:22:50 (UTC)
committer erik <erik>2007-01-26 20:22:50 (UTC)
commit53d630c9c4813142ee13e6843c30476a5db26e78 (patch) (unidiff)
tree50a77a94cfeaccbb3d993bced8b7d0f498f74c7c /core/apps/embeddedkonsole
parent152a8fe978851aea8dac6ae5cb11f73540746b83 (diff)
downloadopie-53d630c9c4813142ee13e6843c30476a5db26e78.zip
opie-53d630c9c4813142ee13e6843c30476a5db26e78.tar.gz
opie-53d630c9c4813142ee13e6843c30476a5db26e78.tar.bz2
Each file in this commit exhibit an example of what prevent calls
'reverse inull'. All that means is that a pointer gets dereferenced. Then a pointer gets checked for validity before being dereferenced again. This almost always points to shenanigans. For example, the konsole.cpp file has this konsoleInit() call which passes in a const char** shell variable. Since it is a double pointer the programmer who wrote the code made the mistake of mixing the checking of the pointer and the pointer that points to the pointer. This commit attempts to correct that. Of course there are other instances of the same thing. But they all boil down to a small mistake which might have produced strange side effects.
Diffstat (limited to 'core/apps/embeddedkonsole') (more/less context) (show whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index f4ca0bf..5c40569 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -217,10 +217,16 @@ static void konsoleInit(const char** shell) {
217 QPEApplication::grabKeyboard(); // for CTRL and ALT 217 QPEApplication::grabKeyboard(); // for CTRL and ALT
218#endif 218#endif
219 219
220 if (!shell) {
221 owarn << "No double pointer 'shell'" << oendl;
222 return;
223 }
224
220 *shell = getenv("SHELL"); 225 *shell = getenv("SHELL");
221 owarn << "SHell initially is " << *shell << "" << oendl; 226 if (*shell)
227 owarn << "Current shell: " << *shell << "" << oendl;
222 228
223 if (shell == NULL || *shell == '\0') { 229 if (*shell == NULL || **shell == '\0') {
224 struct passwd *ent = 0; 230 struct passwd *ent = 0;
225 uid_t me = getuid(); 231 uid_t me = getuid();
226 *shell = "/bin/sh"; 232 *shell = "/bin/sh";