Kaynağa Gözat

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

tags/v0.9.3
Michael Brown 18 yıl önce
ebeveyn
işleme
7dc50167bb
1 değiştirilmiş dosya ile 9 ekleme ve 0 silme
  1. 9
    0
      src/core/image.c

+ 9
- 0
src/core/image.c Dosyayı Görüntüle

@@ -116,6 +116,11 @@ struct image * find_image ( const char *name ) {
116 116
 static int image_load_type ( struct image *image, struct image_type *type ) {
117 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 124
 	if ( ( rc = type->load ( image ) ) != 0 ) {
120 125
 		DBGC ( image, "IMAGE %p could not load as %s: %s\n",
121 126
 		       image, type->name, strerror ( rc ) );
@@ -180,6 +185,10 @@ int image_exec ( struct image *image ) {
180 185
 
181 186
 	assert ( image->type != NULL );
182 187
 
188
+	/* Check that image is actually executable */
189
+	if ( ! image->type->exec )
190
+		return -ENOEXEC;
191
+
183 192
 	/* Try executing the image */
184 193
 	if ( ( rc = image->type->exec ( image ) ) != 0 ) {
185 194
 		DBGC ( image, "IMAGE %p could not execute: %s\n",

Loading…
İptal
Kaydet