Skip to content
Browse files

avoid sv2mortal on returned value. Prevents a free issue when using s…

…uraface with an anonymous surface
  • Loading branch information...
1 parent 4046e91 commit d850194817f577becac77ed9c7db63edc07fd0db @dod38fr dod38fr committed Oct 14, 2011
Showing with 14 additions and 6 deletions.
  1. +14 −6 src/SDLx/Validate.xs
View
20 src/SDLx/Validate.xs
@@ -117,15 +117,23 @@ val_rect( r )
OUTPUT:
RETVAL
-SV *
+void *
val_surface( s )
SV* s
- CODE:
- RETVAL = surface(s);
- if(NULL == RETVAL)
+ PPCODE:
+ SV* ret ;
+ printf("s\n");
+ sv_dump(s) ;
+ ret = surface(s);
+ printf("ret\n");
+ sv_dump(ret);
+ if(NULL == ret)
XSRETURN_UNDEF;
- OUTPUT:
- RETVAL
+ else {
+ /* s (hence ret) is already mortal */
+ ST(0) = ret ;
+ XSRETURN(1) ;
+ }
SV *
val_map_rgb( color, format)

0 comments on commit d850194

Please sign in to comment.
Something went wrong with that request. Please try again.