From b49c23f7f948a2f453b4a8580e52692742e6163f Mon Sep 17 00:00:00 2001 From: giraffedata Date: Thu, 21 Jul 2022 18:22:31 +0000 Subject: check for null font name; clean up other command line validation git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4366 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- generator/pbmtextps.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'generator') diff --git a/generator/pbmtextps.c b/generator/pbmtextps.c index 0c3656e7..a3e9124a 100644 --- a/generator/pbmtextps.c +++ b/generator/pbmtextps.c @@ -52,6 +52,9 @@ validateFontName(const char * const name) { -----------------------------------------------------------------------------*/ unsigned int idx; + if (name[0] == '\0') + pm_error("Font name is empty string"); + for (idx = 0; name[idx] != '\0'; ++idx) { char const c = name[idx]; @@ -244,6 +247,8 @@ parseCommandLine(int argc, const char ** argv, validateFontName(cmdlineP->font); + if (cmdlineP->res <= 0) + pm_error("-resolution must be positive"); if (cmdlineP->fontsize <= 0) pm_error("-fontsize must be positive"); if (cmdlineP->ascent < 0) @@ -413,11 +418,8 @@ gsArgList(const char * const outputFilename, const char ** retval; unsigned int argCt; /* Number of arguments in 'retval' so far */ - if (cmdline.res <= 0) - pm_error("Resolution (dpi) must be positive."); - - if (cmdline.fontsize <= 0) - pm_error("Font size must be positive."); + assert(cmdline.res > 0); + assert(cmdline.fontsize > 0); MALLOCARRAY_NOFAIL(retval, maxArgCt+2); -- cgit 1.4.1