From 431099b1d5f8082bef64c86381ea4c27936d2d1b Mon Sep 17 00:00:00 2001 From: Aaron Puchert Date: Mon, 18 Jun 2018 15:59:11 +0200 Subject: Set error codes in proj_create and proj_create_argv When there are no arguments, we set PJD_ERR_NO_ARGS, just like the old API does in that case. On allocation failure we set ENOMEM as usual. --- src/proj_4D_api.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/proj_4D_api.c b/src/proj_4D_api.c index c21b6278..a6a8dc27 100644 --- a/src/proj_4D_api.c +++ b/src/proj_4D_api.c @@ -560,13 +560,16 @@ PJ *proj_create (PJ_CONTEXT *ctx, const char *definition) { /* Make a copy that we can manipulate */ n = strlen (definition); args = (char *) malloc (n + 1); - if (0==args) + if (0==args) { + proj_context_errno_set(ctx, ENOMEM); return 0; + } strcpy (args, definition); argc = pj_trim_argc (args); if (argc==0) { pj_dealloc (args); + proj_context_errno_set(ctx, PJD_ERR_NO_ARGS); return 0; } @@ -600,15 +603,19 @@ indicator, as in {"+proj=utm", "+zone=32"}, or leave it out, as in {"proj=utm", PJ *P; const char *c; - if (0==argv) - return 0; if (0==ctx) ctx = pj_get_default_ctx (); + if (0==argv) { + proj_context_errno_set(ctx, PJD_ERR_NO_ARGS); + return 0; + } /* We assume that free format is used, and build a full proj_create compatible string */ c = pj_make_args (argc, argv); - if (0==c) + if (0==c) { + proj_context_errno_set(ctx, ENOMEM); return 0; + } P = proj_create (ctx, c); -- cgit v1.2.3