Browse Source

Allow load() and exec() methods to be NULL.

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
7dc50167bb
1 changed files with 9 additions and 0 deletions
  1. 9
    0
      src/core/image.c

+ 9
- 0
src/core/image.c View File

116
 static int image_load_type ( struct image *image, struct image_type *type ) {
116
 static int image_load_type ( struct image *image, struct image_type *type ) {
117
 	int rc;
117
 	int rc;
118
 
118
 
119
+	/* Check image is actually loadable */
120
+	if ( ! type->load )
121
+		return -ENOEXEC;
122
+
123
+	/* Try the image loader */
119
 	if ( ( rc = type->load ( image ) ) != 0 ) {
124
 	if ( ( rc = type->load ( image ) ) != 0 ) {
120
 		DBGC ( image, "IMAGE %p could not load as %s: %s\n",
125
 		DBGC ( image, "IMAGE %p could not load as %s: %s\n",
121
 		       image, type->name, strerror ( rc ) );
126
 		       image, type->name, strerror ( rc ) );
180
 
185
 
181
 	assert ( image->type != NULL );
186
 	assert ( image->type != NULL );
182
 
187
 
188
+	/* Check that image is actually executable */
189
+	if ( ! image->type->exec )
190
+		return -ENOEXEC;
191
+
183
 	/* Try executing the image */
192
 	/* Try executing the image */
184
 	if ( ( rc = image->type->exec ( image ) ) != 0 ) {
193
 	if ( ( rc = image->type->exec ( image ) ) != 0 ) {
185
 		DBGC ( image, "IMAGE %p could not execute: %s\n",
194
 		DBGC ( image, "IMAGE %p could not execute: %s\n",

Loading…
Cancel
Save