File: memcpy

package info (click to toggle)
mig 1.8%2Bgit20221221-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,468 kB
  • sloc: ansic: 4,974; sh: 4,547; yacc: 603; lex: 287; makefile: 121; awk: 45
file content (63 lines) | stat: -rw-r--r-- 2,524 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
commit 6808d2ac6c1b47ad691284152aa58c95a3983048
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Thu Feb 2 19:46:17 2023 +0100

    Avoid passing NULL to memcpy

diff --git a/server.c b/server.c
index 3a09aa2..69c3678 100644
--- a/server.c
+++ b/server.c
@@ -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 * ",
diff --git a/user.c b/user.c
index a189e75..e951ee2 100644
--- a/user.c
+++ b/user.c
@@ -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);