diff --git a/src/iotjs_util.c b/src/iotjs_util.c index 598d8649f2..be0e78f9fd 100644 --- a/src/iotjs_util.c +++ b/src/iotjs_util.c @@ -27,7 +27,10 @@ iotjs_string_t iotjs_file_read(const char* path) { FILE* file = fopen(path, "rb"); - IOTJS_ASSERT(file != NULL); + if (file == NULL) { + iotjs_string_t empty_content = iotjs_string_create(); + return empty_content; + } fseek(file, 0, SEEK_END); long ftell_ret = ftell(file); diff --git a/src/platform/linux/iotjs_module_pwm-linux.c b/src/platform/linux/iotjs_module_pwm-linux.c index bfca967273..1b1d8137da 100644 --- a/src/platform/linux/iotjs_module_pwm-linux.c +++ b/src/platform/linux/iotjs_module_pwm-linux.c @@ -140,7 +140,7 @@ bool iotjs_pwm_set_period(iotjs_pwm_t* pwm) { if (snprintf(buf, sizeof(buf), "%d", value) > 0) { result = iotjs_systemio_open_write_close(devicePath, buf); } - free(devicePath); + iotjs_buffer_release(devicePath); } } return result; @@ -169,7 +169,7 @@ bool iotjs_pwm_set_dutycycle(iotjs_pwm_t* pwm) { } result = iotjs_systemio_open_write_close(devicePath, buf); - free(devicePath); + iotjs_buffer_release(devicePath); } } return result; @@ -195,7 +195,7 @@ bool iotjs_pwm_set_enable(iotjs_pwm_t* pwm) { } result = iotjs_systemio_open_write_close(devicePath, buf); - free(devicePath); + iotjs_buffer_release(devicePath); } return result; }