Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/modules/luacore check lua_tostring()'s return value



details:   https://anonhg.NetBSD.org/src/rev/59a9815e1dce
branches:  trunk
changeset: 790601:59a9815e1dce
user:      mbalmer <mbalmer%NetBSD.org@localhost>
date:      Fri Oct 18 07:46:55 2013 +0000

description:
check lua_tostring()'s return value

diffstat:

 sys/modules/luacore/luacore.c |  58 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 47 insertions(+), 11 deletions(-)

diffs (123 lines):

diff -r 2eb6d38eccb7 -r 59a9815e1dce sys/modules/luacore/luacore.c
--- a/sys/modules/luacore/luacore.c     Fri Oct 18 02:20:15 2013 +0000
+++ b/sys/modules/luacore/luacore.c     Fri Oct 18 07:46:55 2013 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD */
+/*     $NetBSD: luacore.c,v 1.3 2013/10/18 07:46:55 mbalmer Exp $ */
 
 /*
- * Copyright (c) 2011, Marc Balmer <mbalmer%NetBSD.org@localhost>.
+ * Copyright (c) 2011, 2013 Marc Balmer <mbalmer%NetBSD.org@localhost>.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -47,56 +47,88 @@
 static int
 print(lua_State *L)
 {
-       printf("%s", lua_tostring(L, -1));
+       const char *s;
+
+       s = lua_tostring(L, -1);
+       if (s)
+               printf("%s", s);
        return 0;
 }
 
 static int
 print_nolog(lua_State *L)
 {
-       printf_nolog("%s", lua_tostring(L, -1));
+       const char *s;
+
+       s = lua_tostring(L, -1);
+       if (s)
+               printf_nolog("%s", s);
        return 0;
 }
 
 static int
 uprint(lua_State *L)
 {
-       uprintf("%s", lua_tostring(L, -1));
+       const char *s;
+
+       s = lua_tostring(L, -1);
+       if (s)
+               uprintf("%s", s);
        return 0;
 }
 
 static int
 core_aprint_normal(lua_State *L)
 {
-       aprint_normal("%s", lua_tostring(L, -1));
+       const char *s;
+
+       s = lua_tostring(L, -1);
+       if (s)
+               aprint_normal("%s", s);
        return 0;
 }
 
 static int
 core_aprint_naive(lua_State *L)
 {
-       aprint_naive("%s", lua_tostring(L, -1));
+       const char *s;
+
+       s = lua_tostring(L, -1);
+       if (s)
+               aprint_naive("%s", s);
        return 0;
 }
 
 static int
 core_aprint_verbose(lua_State *L)
 {
-       aprint_verbose("%s", lua_tostring(L, -1));
+       const char *s;
+
+       s = lua_tostring(L, -1);
+       if (s)
+               aprint_verbose("%s", s);
        return 0;
 }
 
 static int
 core_aprint_debug(lua_State *L)
 {
-       aprint_debug("%s", lua_tostring(L, -1));
+       const char *s;
+
+       s = lua_tostring(L, -1);
+       if (s)
+               aprint_debug("%s", s);
        return 0;
 }
 
 static int
 core_aprint_error(lua_State *L)
 {
-       aprint_error("%s", lua_tostring(L, -1));
+       const char *s;
+
+       s = lua_tostring(L, -1);
+       if (s)
+               aprint_error("%s", s);
        return 0;
 }
 
@@ -112,7 +144,11 @@
 static int
 core_panic(lua_State *L)
 {
-       panic("%s", lua_tostring(L, -1));
+       const char *s;
+
+       s = lua_tostring(L, -1);
+       if (s)
+               panic("%s", s);
        return 0;
 }
 



Home | Main Index | Thread Index | Old Index