diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-02-02 19:46:17 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-02-02 19:46:17 +0100 |
commit | 6808d2ac6c1b47ad691284152aa58c95a3983048 (patch) | |
tree | 54198d91cae743db68d79e9536768ad821af3bdd | |
parent | a9db7bcc04530e19223b5037bb8420fa4344b183 (diff) | |
download | mig-6808d2ac6c1b47ad691284152aa58c95a3983048.tar.gz mig-6808d2ac6c1b47ad691284152aa58c95a3983048.tar.bz2 mig-6808d2ac6c1b47ad691284152aa58c95a3983048.zip |
Avoid passing NULL to memcpy
-rw-r--r-- | server.c | 5 | ||||
-rw-r--r-- | user.c | 9 |
2 files changed, 9 insertions, 5 deletions
@@ -994,7 +994,10 @@ WritePackArgValue(FILE *file, const argument_t *arg) fprintf(file, "\t\tmsgh_simple = FALSE;\n"); fprintf(file, "\t}\n\telse {\n\t"); } - fprintf(file, "\tmemcpy(OutP->%s, %s, ", + fprintf(file, "\tif (%s)\n", count->argVarName); + if (it->itIndefinite) + fprintf(file, "\t"); + fprintf(file, "\t\tmemcpy(OutP->%s, %s, ", arg->argMsgField, arg->argVarName); if (btype->itTypeSize > 1) fprintf(file, "%d * ", @@ -455,7 +455,7 @@ WritePackArgValue(FILE *file, const argument_t *arg) else WriteMsgError(file, arg->argRoutine, "MIG_ARRAY_TOO_LARGE"); - fprintf(file, "\t}\n\telse {\n"); + fprintf(file, "\t}\n\telse if (%s%s) {\n", countRef, count->argVarName); fprintf(file, "\t\tmemcpy(InP->%s, %s%s, ", arg->argMsgField, ref, arg->argVarName); @@ -968,7 +968,7 @@ WriteExtractArgValue(FILE *file, const argument_t *arg) fprintf(file, "%d * ", btype->itTypeSize/btype->itNumber); fprintf(file, "OutP->%s);\n", count->argMsgField); fprintf(file, "\t}\n"); - fprintf(file, "\telse {\n"); + fprintf(file, "\telse if (OutP->%s) {\n", count->argMsgField); fprintf(file, "\t memcpy(%s%s, OutP->%s, ", ref, arg->argVarName, arg->argMsgField); @@ -1001,7 +1001,8 @@ WriteExtractArgValue(FILE *file, const argument_t *arg) * fill user`s area as much as possible. Return the correct * number of elements. */ - fprintf(file, "\t\tmemcpy(%s%s, OutP->%s, ", ref, arg->argVarName, + fprintf(file, "\t\tif (%s%s)\n", countRef, count->argVarName); + fprintf(file, "\t\t\tmemcpy(%s%s, OutP->%s, ", ref, arg->argVarName, arg->argMsgField); if (btype->itTypeSize > 1) fprintf(file, "%d * ", btype->itTypeSize); @@ -1015,7 +1016,7 @@ WriteExtractArgValue(FILE *file, const argument_t *arg) fprintf(file, ";\n"); WriteMsgError(file,arg->argRoutine, "MIG_ARRAY_TOO_LARGE"); - fprintf(file, "\t}\n\telse {\n"); + fprintf(file, "\t}\n\telse if (OutP->%s) {\n", count->argMsgField); fprintf(file, "\t\tmemcpy(%s%s, OutP->%s, ", ref, arg->argVarName, arg->argMsgField); |