You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by ma...@apache.org on 2025/01/03 05:22:11 UTC

(cloudberry) branch main updated: src/timezone/zic.c: handle strdup failure (#836)

This is an automated email from the ASF dual-hosted git repository.

maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git


The following commit(s) were added to refs/heads/main by this push:
     new 63f7c13ef3 src/timezone/zic.c: handle strdup failure (#836)
63f7c13ef3 is described below

commit 63f7c13ef38b0110adc9352f971bc231c3957a8b
Author: Ilya Shipitsin <ch...@gmail.com>
AuthorDate: Fri Jan 3 06:22:07 2025 +0100

    src/timezone/zic.c: handle strdup failure (#836)
    
    When OOM occurs, strdup returns NULL to indicate insufficient memory, and the program needs to exit instead
    of continuing to execute.
---
 src/timezone/zic.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/timezone/zic.c b/src/timezone/zic.c
index 0ea6ead2db..7548bb76a7 100644
--- a/src/timezone/zic.c
+++ b/src/timezone/zic.c
@@ -700,8 +700,15 @@ main(int argc, char **argv)
 					error(_("invalid option: -b '%s'"), optarg);
 				break;
 			case 'd':
-				if (directory == NULL)
+				if (directory == NULL) {
 					directory = strdup(optarg);
+					if (directory == NULL) {
+						fprintf(stderr,
+								_("%s: Out of memory\n"),
+								progname);
+						return EXIT_FAILURE;
+					}
+				}
 				else
 				{
 					fprintf(stderr,


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org