cinera.c: Fix segfault on partial hmmlib1 credit
This commit is contained in:
parent
b0501d20ac
commit
07795b7cbd
|
@ -23,7 +23,7 @@ typedef struct
|
|||
version CINERA_APP_VERSION = {
|
||||
.Major = 0,
|
||||
.Minor = 8,
|
||||
.Patch = 17
|
||||
.Patch = 18
|
||||
};
|
||||
|
||||
#include <stdarg.h> // NOTE(matt): varargs
|
||||
|
@ -6687,17 +6687,26 @@ void
|
|||
ErrorRole(string HMMLFilepath, string Role)
|
||||
{
|
||||
ErrorFilenameAndLineNumber(&HMMLFilepath, 0, S_ERROR, ED_INDEXING);
|
||||
fprintf(stderr, "No such role: %s%.*s%s\n",
|
||||
ColourStrings[CS_YELLOW_BOLD],
|
||||
(int)Role.Length, Role.Base,
|
||||
ColourStrings[CS_END]);
|
||||
fprintf(stderr, "Perhaps you'd like to add a new role to your config file, e.g.:\n"
|
||||
" role = \"%.*s\"\n"
|
||||
" {\n"
|
||||
" name = \"Roller\";\n"
|
||||
" plural = \"Rollae\";\n"
|
||||
" position = -1;\n"
|
||||
" }\n", (int)Role.Length, Role.Base);
|
||||
if(Role.Length == 0)
|
||||
{
|
||||
fprintf(stderr, "Credit lacks a role\n");
|
||||
fprintf(stderr, " A complete credit takes the form:\n"
|
||||
" credit = creditable_person:their_role\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "No such role: %s%.*s%s\n",
|
||||
ColourStrings[CS_YELLOW_BOLD],
|
||||
(int)Role.Length, Role.Base,
|
||||
ColourStrings[CS_END]);
|
||||
fprintf(stderr, "Perhaps you'd like to add a new role to your config file, e.g.:\n"
|
||||
" role = \"%.*s\"\n"
|
||||
" {\n"
|
||||
" name = \"Roller\";\n"
|
||||
" plural = \"Rollae\";\n"
|
||||
" position = -1;\n"
|
||||
" }\n", (int)Role.Length, Role.Base);
|
||||
}
|
||||
WaitForInput();
|
||||
}
|
||||
#endif
|
||||
|
@ -6800,6 +6809,12 @@ Uncredited(HMML_VideoMetaData *Metadata, credit *C)
|
|||
return Result;
|
||||
}
|
||||
|
||||
bool
|
||||
IsValidCredit(credit *Credit)
|
||||
{
|
||||
return Credit->Person && Credit->Role;
|
||||
}
|
||||
|
||||
void
|
||||
MergeCredits(memory_book *Credits, project *CurrentProject, HMML_VideoMetaData *Metadata)
|
||||
{
|
||||
|
@ -6807,7 +6822,7 @@ MergeCredits(memory_book *Credits, project *CurrentProject, HMML_VideoMetaData *
|
|||
for(int ProjectCreditIndex = 0; ProjectCreditIndex < CurrentProject->Credit.ItemCount; ++ProjectCreditIndex)
|
||||
{
|
||||
credit *Credit = GetPlaceInBook(&CurrentProject->Credit, ProjectCreditIndex);
|
||||
if(!Uncredited(Metadata, Credit) && Credit->Role && !GetCredit(Credits, Credit))
|
||||
if(IsValidCredit(Credit) && !Uncredited(Metadata, Credit) && !GetCredit(Credits, Credit))
|
||||
{
|
||||
credit *New = MakeSpaceInBook(Credits);
|
||||
New->Person = Credit->Person;
|
||||
|
@ -6821,7 +6836,7 @@ MergeCredits(memory_book *Credits, project *CurrentProject, HMML_VideoMetaData *
|
|||
credit Credit = {};
|
||||
Credit.Person = GetPersonFromConfig(Wrap0(This->name));
|
||||
Credit.Role = GetRoleByID(Config, Wrap0(This->role));
|
||||
if(!Uncredited(Metadata, &Credit) && Credit.Role && !GetCredit(Credits, &Credit))
|
||||
if(IsValidCredit(&Credit) && !Uncredited(Metadata, &Credit) && !GetCredit(Credits, &Credit))
|
||||
{
|
||||
credit *New = MakeSpaceInBook(Credits);
|
||||
New->Person = Credit.Person;
|
||||
|
@ -6840,7 +6855,7 @@ MergeCredits(memory_book *Credits, project *CurrentProject, HMML_VideoMetaData *
|
|||
credit Credit = {};
|
||||
Credit.Person = GetPersonFromConfig(Wrap0(This->value));
|
||||
Credit.Role = GetRoleByID(Config, Wrap0(RoleIDStrings[ThisAttribute->RoleID]));
|
||||
if(!Uncredited(Metadata, &Credit) && Credit.Role && !GetCredit(Credits, &Credit))
|
||||
if(IsValidCredit(&Credit) && !Uncredited(Metadata, &Credit) && !GetCredit(Credits, &Credit))
|
||||
{
|
||||
credit *New = MakeSpaceInBook(Credits);
|
||||
New->Person = Credit.Person;
|
||||
|
|
Loading…
Reference in New Issue