Code Room
Code reviewHardcr-g161
Subject Memory safetyLevel Senior–Staff~30 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this C resource-cleanup path.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewc
#include <stdlib.h> int load(const char *path, char **out) {    char *buf = malloc(1024);    if (!buf) return -1;    if (read_file(path, buf, 1024) < 0) {        free(buf);        goto fail;    }    *out = buf;    return 0;fail:    free(buf);    return -1;}
Run or narrate your approach, then ask the coach.