Skip to contentSkip to conversation

: Add check for realloc failure case

PATCH Cyril Hrubis 1 participant 1 message Jun 4, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 149090115.398111433218346536.JavaMail.weblogic@epmlwas08b

#1 lore raw

Hi!

Review const char **splitstr(const char *str, const char *separator, int *argcount) · line 119

Quoted 7 lines
(quoted diff) +3 -0
@@ -113,6 +114,12 @@ const char **splitstr(const char *str, const char *separator, int *argcount)
 			arg_array =
 			    (char **)realloc((void *)arg_array,
 					     sizeof(char *) * max_toks);
+			if (arg_array == NULL) {
+				fprintf(stderr, "realloc: New memory allocation failed \n");
+				free(arg_array);

I've removed the free(arg_array) here, because it's noop (doing free(NULL)) and pushed both patches.

Signature · 8 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list