瀏覽代碼

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

tags/v0.9.3
Michael Brown 18 年之前
父節點
當前提交
7dc50167bb
共有 1 個檔案被更改,包括 9 行新增0 行删除
  1. 9
    0
      src/core/image.c

+ 9
- 0
src/core/image.c 查看文件

@@ -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…
取消
儲存