From f2885547ffdbf07e548b42000791a3be6041e110 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 12 Feb 2017 05:36:08 +0100 Subject: [PATCH] libplatforminfo: make sanitize_image_name() fail gracefully Some targets may not always have a /tmp/sysinfo/model, don't crash in this case. --- libs/libplatforminfo/src/common.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/libplatforminfo/src/common.h b/libs/libplatforminfo/src/common.h index 11667b1..8d71c5c 100644 --- a/libs/libplatforminfo/src/common.h +++ b/libs/libplatforminfo/src/common.h @@ -61,6 +61,11 @@ __attribute__((unused)) static char * read_line(const char *filename) { } __attribute__((unused)) static void sanitize_image_name(char **outp, char *in) { + if (!in) { + *outp = NULL; + return; + } + char *out = malloc(strlen(in) + 1); *outp = out;