| File: | ActionHook.c |
| Location: | line 105, column 18 |
| Description: | Access to field 'action_hook_list' results in a dereference of a null pointer (loaded from variable 'app') |
| 1 | /*LINTLIBRARY*/ |
| 2 | |
| 3 | /*********************************************************** |
| 4 | Copyright (c) 1993, Oracle and/or its affiliates. All rights reserved. |
| 5 | |
| 6 | Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | copy of this software and associated documentation files (the "Software"), |
| 8 | to deal in the Software without restriction, including without limitation |
| 9 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | and/or sell copies of the Software, and to permit persons to whom the |
| 11 | Software is furnished to do so, subject to the following conditions: |
| 12 | |
| 13 | The above copyright notice and this permission notice (including the next |
| 14 | paragraph) shall be included in all copies or substantial portions of the |
| 15 | Software. |
| 16 | |
| 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 23 | DEALINGS IN THE SOFTWARE. |
| 24 | |
| 25 | Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. |
| 26 | |
| 27 | All Rights Reserved |
| 28 | |
| 29 | Permission to use, copy, modify, and distribute this software and its |
| 30 | documentation for any purpose and without fee is hereby granted, |
| 31 | provided that the above copyright notice appear in all copies and that |
| 32 | both that copyright notice and this permission notice appear in |
| 33 | supporting documentation, and that the name of Digital not be |
| 34 | used in advertising or publicity pertaining to distribution of the |
| 35 | software without specific, written prior permission. |
| 36 | |
| 37 | DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING |
| 38 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL |
| 39 | DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR |
| 40 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, |
| 41 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
| 42 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
| 43 | SOFTWARE. |
| 44 | |
| 45 | ******************************************************************/ |
| 46 | |
| 47 | /* |
| 48 | |
| 49 | Copyright 1987, 1988, 1998 The Open Group |
| 50 | |
| 51 | Permission to use, copy, modify, distribute, and sell this software and its |
| 52 | documentation for any purpose is hereby granted without fee, provided that |
| 53 | the above copyright notice appear in all copies and that both that |
| 54 | copyright notice and this permission notice appear in supporting |
| 55 | documentation. |
| 56 | |
| 57 | The above copyright notice and this permission notice shall be included in |
| 58 | all copies or substantial portions of the Software. |
| 59 | |
| 60 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 61 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 62 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 63 | OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 64 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 65 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 66 | |
| 67 | Except as contained in this notice, the name of The Open Group shall not be |
| 68 | used in advertising or otherwise to promote the sale, use or other dealings |
| 69 | in this Software without prior written authorization from The Open Group. |
| 70 | |
| 71 | */ |
| 72 | |
| 73 | /* |
| 74 | * Contains XtAppAddActionHook, XtRemoveActionHook |
| 75 | */ |
| 76 | |
| 77 | #ifdef HAVE_CONFIG_H1 |
| 78 | #include <config.h> |
| 79 | #endif |
| 80 | #include "IntrinsicI.h" |
| 81 | |
| 82 | |
| 83 | /*ARGSUSED*/ |
| 84 | static void FreeActionHookList( |
| 85 | Widget widget, /* unused (and invalid) */ |
| 86 | XtPointer closure, /* ActionHook* */ |
| 87 | XtPointer call_data) /* unused */ |
| 88 | { |
| 89 | ActionHook list = *(ActionHook*)closure; |
| 90 | while (list != NULL((void*)0)) { |
| 91 | ActionHook next = list->next; |
| 92 | XtFree( (XtPointer)list ); |
| 93 | list = next; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | |
| 98 | XtActionHookId XtAppAddActionHook( |
| 99 | XtAppContext app, |
| 100 | XtActionHookProc proc, |
| 101 | XtPointer closure) |
| 102 | { |
| 103 | ActionHook hook = XtNew(ActionHookRec)((ActionHookRec *) XtMalloc((unsigned) sizeof(ActionHookRec)) ); |
| 104 | LOCK_APP(app)if(app && app->lock)(*app->lock)(app); |
| 105 | hook->next = app->action_hook_list; |
Access to field 'action_hook_list' results in a dereference of a null pointer (loaded from variable 'app') | |
| 106 | hook->app = app; |
| 107 | hook->proc = proc; |
| 108 | hook->closure = closure; |
| 109 | if (app->action_hook_list == NULL((void*)0)) { |
| 110 | _XtAddCallback( &app->destroy_callbacks, |
| 111 | FreeActionHookList, |
| 112 | (XtPointer)&app->action_hook_list |
| 113 | ); |
| 114 | } |
| 115 | app->action_hook_list = hook; |
| 116 | UNLOCK_APP(app)if(app && app->unlock)(*app->unlock)(app); |
| 117 | return (XtActionHookId)hook; |
| 118 | } |
| 119 | |
| 120 | |
| 121 | void XtRemoveActionHook( |
| 122 | XtActionHookId id) |
| 123 | { |
| 124 | ActionHook *p, hook = (ActionHook)id; |
| 125 | XtAppContext app = hook->app; |
| 126 | LOCK_APP(app)if(app && app->lock)(*app->lock)(app); |
| 127 | for (p = &app->action_hook_list; p != NULL((void*)0) && *p != hook; p = &(*p)->next); |
| 128 | if (p) { |
| 129 | *p = hook->next; |
| 130 | XtFree( (XtPointer)hook ); |
| 131 | if (app->action_hook_list == NULL((void*)0)) |
| 132 | _XtRemoveCallback(&app->destroy_callbacks, FreeActionHookList, |
| 133 | (XtPointer) &app->action_hook_list); |
| 134 | } |
| 135 | #ifdef DEBUG |
| 136 | else { |
| 137 | XtAppWarningMsg(app, "badId", "xtRemoveActionHook", XtCXtToolkitError, |
| 138 | "XtRemoveActionHook called with bad or old hook id", |
| 139 | (String*)NULL((void*)0), (Cardinal*)NULL((void*)0)); |
| 140 | } |
| 141 | #endif /*DEBUG*/ |
| 142 | UNLOCK_APP(app)if(app && app->unlock)(*app->unlock)(app); |
| 143 | } |