Fix memory allocation calculations and check for NULL pointer returns.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
#ifdef HAVE_DLOPEN
#include <dlfcn.h>
#endif
+#include <errno.h>
int ss_create_invocation(subsystem_name, version_string, info_ptr,
request_table_ptr, code_ptr)
;
table = (ss_data **) realloc((char *)table,
((unsigned)sci_idx+2)*size);
+ if (table == NULL) {
+ *code_ptr = errno;
+ return 0;
+ }
table[sci_idx+1] = (ss_data *) NULL;
table[sci_idx] = new_table;
parse_mode = TOKEN;
cp = line_ptr;
argv = NEW_ARGV (argv, argc);
+ if (argv == NULL) {
+ *argc_ptr = errno;
+ return argv;
+ }
argv[argc++] = line_ptr;
argv[argc] = NULL;
}
;
/* size == C subscript of NULL == #elements */
size += 2; /* new element, and NULL */
- t = (ssrt **)realloc(info->rqt_tables, (unsigned)size*sizeof(ssrt));
+ t = (ssrt **)realloc(info->rqt_tables, (unsigned)size*sizeof(ssrt *));
if (t == (ssrt **)NULL) {
*code_ptr = errno;
return;