coccinelle: make use of the "type" FREE_AND_NULL() rule
[gitweb.git] / builtin / am.c
index 8881d736151bf266cc8544a717cba960c078eff5..138fb98537c53a2dd5ed1557f5774d73fdc08a8a 100644 (file)
@@ -483,8 +483,7 @@ static int run_applypatch_msg_hook(struct am_state *state)
        ret = run_hook_le(NULL, "applypatch-msg", am_path(state, "final-commit"), NULL);
 
        if (!ret) {
-               free(state->msg);
-               state->msg = NULL;
+               FREE_AND_NULL(state->msg);
                if (read_commit_msg(state) < 0)
                        die(_("'%s' was deleted by the applypatch-msg hook"),
                                am_path(state, "final-commit"));