Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Diff of /src/dvdnav_internal.h [4ec9b7] .. [b93183] Maximize Restore

  Switch to side-by-side view

--- a/src/dvdnav_internal.h
+++ b/src/dvdnav_internal.h
@@ -186,14 +186,18 @@
 /** USEFUL MACROS **/
 
 #ifdef __GNUC__
-#define printerrf(format, args...) snprintf(this->err_str, MAX_ERR_LEN, format, ## args);
+#define printerrf(format, args...) \
+	do { if (this) snprintf(this->err_str, MAX_ERR_LEN, format, ## args); } while (0)
 #else
 #ifdef _MSC_VER
-#define printerrf(str) snprintf(this->err_str, MAX_ERR_LEN, str);
-#else
-#define printerrf(...) snprintf(this->err_str, MAX_ERR_LEN, __VA_ARGS__);
+#define printerrf(str) \
+	do { if (this) snprintf(this->err_str, MAX_ERR_LEN, str); } while (0)
+#else
+#define printerrf(...) \
+	do { if (this) snprintf(this->err_str, MAX_ERR_LEN, __VA_ARGS__); } while (0)
 #endif /* WIN32 */
 #endif
-#define printerr(str) strncpy(this->err_str, str, MAX_ERR_LEN);
+#define printerr(str) \
+	do { if (this) strncpy(this->err_str, str, MAX_ERR_LEN); } while (0)
 
 #endif /* DVDNAV_INTERNAL_H_INCLUDED */