]> git.meshlink.io Git - utcp/blobdiff - utcp.c
Always check the return value of malloc().
[utcp] / utcp.c
diff --git a/utcp.c b/utcp.c
index 607af2d149ee9242646d3f1a97638ecb64e01078..95a82c428710ca91f5f2752045eea036bee40c79 100644 (file)
--- a/utcp.c
+++ b/utcp.c
@@ -88,6 +88,10 @@ static void print_packet(struct utcp *utcp, const char *dir, const void *pkt, si
        if(len > sizeof hdr) {
                uint32_t datalen = len - sizeof hdr;
                uint8_t *str = malloc((datalen << 1) + 7);
+               if(!str) {
+                       debug("out of memory");
+                       return;
+               }
                memcpy(str, " data=", 6);
                uint8_t *strptr = str + 6;
                const uint8_t *data = pkt;