jcs
/subtext
/amendments
/353
bile: Fix bile_next_id in the case of no highest ID record
jcs made amendment 353 about 1 year ago
--- bile.c Thu Mar 2 09:32:44 2023
+++ bile.c Fri Mar 3 21:39:28 2023
@@ -426,13 +426,17 @@ bile_next_id(struct bile *bile, const OSType type)
id = o->id + 1;
}
- if (bile_read(bile, BILE_TYPE_HIGHESTID, type, &highest,
- sizeof(unsigned long)) == sizeof(unsigned long)) {
- if (highest > id)
- id = highest + 1;
+ o = bile_find(bile, BILE_TYPE_HIGHESTID, type);
+ if (o) {
+ if (bile_read_object(bile, o, &highest,
+ sizeof(unsigned long)) == sizeof(unsigned long)) {
+ if (highest > id)
+ id = highest + 1;
+ }
+ xfree(&o);
+ if (_bile_error)
+ return 0;
}
- if (_bile_error)
- return 0;
return id;
}