Code Room
Code reviewMediumcr-g376
Subject Double freeLevel Mid–Senior~20 minCommon in Code quality & review interviewsIndustries Software development, Telecom

Question

Review this C packet-cloning code used in a forwarding fast 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
typedef struct { uint8_t *payload; size_t len; } Packet; Packet clone_pkt(Packet src) {    Packet dst = src;        // copy fields    dst.len = src.len;    return dst;              // share payload pointer} void handle(Packet p) {    Packet c = clone_pkt(p);    forward(&c);    free(c.payload);    free(p.payload);}
Run or narrate your approach, then ask the coach.