From 0b612977befb7674d8fe8c0f26264370f0daa93b Mon Sep 17 00:00:00 2001 From: prasad-sawantdesai Date: Fri, 3 Apr 2026 08:17:24 +0200 Subject: [PATCH] skip the write of CHAR_DATA when it is empty --- src/imas_mex_casts.c | 5 +++++ src/imas_mex_utils.c | 1 + 2 files changed, 6 insertions(+) diff --git a/src/imas_mex_casts.c b/src/imas_mex_casts.c index d2e997f..eaaf2db 100644 --- a/src/imas_mex_casts.c +++ b/src/imas_mex_casts.c @@ -274,6 +274,11 @@ al_status_t castCellToChar(mxArray ** data) numel = mxGetNumberOfElements(cellData); + if (numel == 0) { + *data = NULL; + return status; + } + strings = malloc(numel*sizeof(char *)); for (i = 0; i < numel; i++) { cell = mxGetCell(*data, (mwIndex) i); diff --git a/src/imas_mex_utils.c b/src/imas_mex_utils.c index 3f63550..ceaecc9 100644 --- a/src/imas_mex_utils.c +++ b/src/imas_mex_utils.c @@ -975,6 +975,7 @@ al_status_t my_al_write_data(struct imas_mex_actionInfo * action, struct imas_me if (field->datatype == CHAR_DATA && field->dim == 2) { if (mxIsCell(data)) { if (status.code >= 0) status = cast_status = castCellToChar((mxArray **) &data); + if (data == NULL) return (al_status_t) {0,""}; } }