diff options
| author | Markus Mittendrein <git@maxmitti.tk> | 2019-03-17 00:12:15 +0100 |
|---|---|---|
| committer | Markus Mittendrein <git@maxmitti.tk> | 2019-03-17 00:12:15 +0100 |
| commit | 63c32f730a6656170a19a31cbe946cf8ed80b119 (patch) | |
| tree | 111caafb4efa14dfe10cdda3bef9f934b06d34ac /src/cc4group.c | |
| parent | 662e74d2a1a045c333542aaf7f2ef60cbf7f726d (diff) | |
| download | cc4group-63c32f730a6656170a19a31cbe946cf8ed80b119.tar.gz cc4group-63c32f730a6656170a19a31cbe946cf8ed80b119.zip | |
Add error checking to error formatters
Diffstat (limited to 'src/cc4group.c')
| -rw-r--r-- | src/cc4group.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/cc4group.c b/src/cc4group.c index 56d307a..7a550cd 100644 --- a/src/cc4group.c +++ b/src/cc4group.c @@ -133,7 +133,10 @@ static char* cc4group_strerrorFormatter(int32_t const code, const char* const me { (void)data; char* message; - asprintf(&message, "%s: %s: %s (%d)", method, causer, strerror(code), code); + if(asprintf(&message, "%s: %s: %s (%d)", method, causer, strerror(code), code) == -1) + { + return NULL; + } return message; } @@ -152,7 +155,10 @@ static char* cc4group_zerrorFormatter(int32_t const code, const char* const meth if(code == CC4GROUP_MEM_ERROR) { errorString = ""; - asprintf(&message, "%s: %s: Can't allocate memory for copying the input data: %s (%d)", method, causer, strerror(storedErrno), storedErrno); + if(asprintf(&message, "%s: %s: Can't allocate memory for copying the input data: %s (%d)", method, causer, strerror(storedErrno), storedErrno) == -1) + { + return NULL; + } return message; } @@ -169,7 +175,10 @@ static char* cc4group_zerrorFormatter(int32_t const code, const char* const meth errorString = zError(code); } - asprintf(&message, "%s: %s: %s (%d)", method, causer, errorString, code); + if(asprintf(&message, "%s: %s: %s (%d)", method, causer, errorString, code) == -1) + { + return NULL; + } return message; } @@ -179,7 +188,10 @@ static char* cc4group_messageFormatter(int32_t const code, const char* const met (void)data; char* message; - asprintf(&message, "%s: %s", method, causer); + if(asprintf(&message, "%s: %s", method, causer) == -1) + { + return NULL; + } return message; } |
