Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

2005-06-16 Al Riddoch <alriddoch@zepler.org>

	* libmd3/loader.c: Fix some error conditions which were not
	  correctly checked or reported.
  • Loading branch information...
commit 7dd2fb2b9469cf44871bfb7820f0b3a441e76e4c 1 parent d556088
@alriddoch authored
Showing with 14 additions and 5 deletions.
  1. +5 −0 ChangeLog
  2. +9 −5 libmd3/loader.c
View
5 ChangeLog
@@ -1,3 +1,8 @@
+2005-06-16 Al Riddoch <alriddoch@zepler.org>
+
+ * libmd3/loader.c: Fix some error conditions which were not
+ correctly checked or reported.
+
2005-06-15 Al Riddoch <alriddoch@zepler.org>
* libmd3/loader.c: Don't free mesh when it fails to load. Free all
View
14 libmd3/loader.c
@@ -300,12 +300,12 @@ static md3_header * libmd3_header_load(FILE * fptr)
size_t len;
md3_header * header = calloc(1, sizeof(md3_header));
if (header == NULL) {
- printf("2\n");
+ perror("calloc");
return NULL;
}
if ((len = fread(header, sizeof(md3_header), 1, fptr)) != 1) {
- printf("3 %d %d\n", len, sizeof(md3_header));
+ fprintf(stderr, "Unexpected end of file.\n");
free(header);
return NULL;
}
@@ -314,7 +314,7 @@ static md3_header * libmd3_header_load(FILE * fptr)
(header->ident[1] != 'D') ||
(header->ident[2] != 'P') ||
(header->ident[3] != '3')) {
- printf("4\n");
+ fprintf(stderr, "File header is not MD3 file.\n");
free(header);
return NULL;
}
@@ -330,15 +330,19 @@ libmd3_file * libmd3_file_load(const char * filename)
fptr = fopen(filename, "rb");
if (fptr == NULL) {
- printf("1\n");
+ fprintf(stderr, "Unable to open file \"%s\".\n", filename);
return NULL;
}
header = libmd3_header_load(fptr);
+ if (header == NULL) {
+ return NULL;
+ }
+
file = calloc(1, sizeof(libmd3_file));
if (file == NULL) {
- printf("5\n");
+ perror("calloc");
free(header);
return NULL;
}
Please sign in to comment.
Something went wrong with that request. Please try again.