]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/safe_sprintf.c
ncurses 6.2 - patch 20210213
[ncurses.git] / ncurses / base / safe_sprintf.c
index 22db3ba7fde1c7617ce944cba30d5c1a7c863483..1868c009660c37751f3c50153a1b7fead64e5f41 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2013,2018 Free Software Foundation, Inc.              *
+ * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 1998-2012,2013 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -33,7 +34,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: safe_sprintf.c,v 1.31 2018/02/17 21:19:41 tom Exp $")
+MODULE_ID("$Id: safe_sprintf.c,v 1.33 2020/02/02 23:34:34 tom Exp $")
 
 #if USE_SAFE_SPRINTF
 
 
 #if USE_SAFE_SPRINTF
 
@@ -41,7 +42,7 @@ typedef enum {
     Flags, Width, Prec, Type, Format
 } PRINTF;
 
     Flags, Width, Prec, Type, Format
 } PRINTF;
 
-#define VA_INTGR(type) ival = va_arg(ap, type)
+#define VA_INTGR(type) ival = (int) va_arg(ap, type)
 #define VA_FLOAT(type) fval = va_arg(ap, type)
 #define VA_POINT(type) pval = (void *)va_arg(ap, type)
 
 #define VA_FLOAT(type) fval = va_arg(ap, type)
 #define VA_POINT(type) pval = (void *)va_arg(ap, type)
 
@@ -157,9 +158,9 @@ _nc_printf_length(const char *fmt, va_list ap)
                    case 's':
                        VA_POINT(char *);
                        if (prec < 0)
                    case 's':
                        VA_POINT(char *);
                        if (prec < 0)
-                           prec = strlen(pval);
+                           prec = (int) strlen(pval);
                        if (prec > (int) length) {
                        if (prec > (int) length) {
-                           length = length + prec;
+                           length = length + (size_t) prec;
                            buffer = typeRealloc(char, length, buffer);
                            if (buffer == 0) {
                                free(format);
                            buffer = typeRealloc(char, length, buffer);
                            if (buffer == 0) {
                                free(format);
@@ -234,7 +235,7 @@ NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_DCLx
        end_va_copy(ap2);
 
        if ((int) my_length < len + 1) {
        end_va_copy(ap2);
 
        if ((int) my_length < len + 1) {
-           my_length = 2 * (len + 1);
+           my_length = (size_t) (2 * (len + 1));
            my_buffer = typeRealloc(char, my_length, my_buffer);
        }
        if (my_buffer != 0) {
            my_buffer = typeRealloc(char, my_length, my_buffer);
        }
        if (my_buffer != 0) {