@@ -395,6 +395,7 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
395395 git_oid parent_id ;
396396 size_t header_len ;
397397 git_signature dummy_sig ;
398+ int error ;
398399
399400 GIT_ASSERT_ARG (commit );
400401 GIT_ASSERT_ARG (data );
@@ -431,14 +432,14 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
431432 commit -> author = git__malloc (sizeof (git_signature ));
432433 GIT_ERROR_CHECK_ALLOC (commit -> author );
433434
434- if (git_signature__parse (commit -> author , & buffer , buffer_end , "author " , '\n' ) < 0 )
435- return -1 ;
435+ if (( error = git_signature__parse (commit -> author , & buffer , buffer_end , "author " , '\n' ) ) < 0 )
436+ return error ;
436437 }
437438
438439 /* Some tools create multiple author fields, ignore the extra ones */
439440 while (!git__prefixncmp (buffer , buffer_end - buffer , "author " )) {
440- if (git_signature__parse (& dummy_sig , & buffer , buffer_end , "author " , '\n' ) < 0 )
441- return -1 ;
441+ if (( error = git_signature__parse (& dummy_sig , & buffer , buffer_end , "author " , '\n' ) ) < 0 )
442+ return error ;
442443
443444 git__free (dummy_sig .name );
444445 git__free (dummy_sig .email );
@@ -448,8 +449,8 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
448449 commit -> committer = git__malloc (sizeof (git_signature ));
449450 GIT_ERROR_CHECK_ALLOC (commit -> committer );
450451
451- if (git_signature__parse (commit -> committer , & buffer , buffer_end , "committer " , '\n' ) < 0 )
452- return -1 ;
452+ if (( error = git_signature__parse (commit -> committer , & buffer , buffer_end , "committer " , '\n' ) ) < 0 )
453+ return error ;
453454
454455 if (flags & GIT_COMMIT_PARSE_QUICK )
455456 return 0 ;
@@ -493,7 +494,7 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
493494
494495bad_buffer :
495496 git_error_set (GIT_ERROR_OBJECT , "failed to parse bad commit object" );
496- return -1 ;
497+ return GIT_EINVALID ;
497498}
498499
499500int git_commit__parse_raw (void * commit , const char * data , size_t size )
@@ -971,8 +972,10 @@ int git_commit_create_with_signature(
971972 /* The first step is to verify that all the tree and parents exist */
972973 parsed = git__calloc (1 , sizeof (git_commit ));
973974 GIT_ERROR_CHECK_ALLOC (parsed );
974- if ((error = commit_parse (parsed , commit_content , strlen (commit_content ), 0 )) < 0 )
975+ if (commit_parse (parsed , commit_content , strlen (commit_content ), 0 ) < 0 ) {
976+ error = -1 ;
975977 goto cleanup ;
978+ }
976979
977980 if ((error = validate_tree_and_parents (& parents , repo , & parsed -> tree_id , commit_parent_from_commit , parsed , NULL , true)) < 0 )
978981 goto cleanup ;
0 commit comments